I don't get any Json response data
I don't get any Json response data
![sanderk](https://secure.gravatar.com/avatar/83013de21f9132ee2dd22e42e8adbbc8/?default=https%3A%2F%2Fvanillicon.com%2F83013de21f9132ee2dd22e42e8adbbc8_200.png&rating=g&size=120)
Hi,
I have the following code:
[Authorize]
public class AdministratiesController : Controller
{
private readonly IConfiguration _configuration;
public AdministratiesController(IConfiguration configuration)
{
_configuration = configuration;
}
[Route("administraties/table")]
[HttpGet]
[HttpPost]
public ActionResult Table()
{
string connectionString = _configuration.GetConnectionString("BBGroepDataContext");
using (var db = new Database("sqlserver", connectionString))
{
var response = new Editor(db, "Administraties")
.Model<Administratie>()
.Field(new Field("Naam")
.Validator(Validation.NotEmpty())
)
.Debug(true)
.TryCatch(false)
.Process(Request)
.Data();
return Json(response);
}
}
}
The reponse contains multiple records, but I don't get any Json written to the browser.
This question has accepted answers - jump to:
This discussion has been closed.
Answers
Can you post the JSON and the table initialisation code too, please.
Colin
I don't get any json response. Just {}
And when I continue
You said the response contains multiple records. Show them to us. Colin also asked to see your DataTable initialisation code.
The screenshot shows the response object has four records. This is the code I have in the HTML page:
Could you add in the
.Debug(true)
like you have in the code in your original post (but not the screenshot) and then use the debugger to give me a trace please - click the Upload button and then let me know what the debug code is.Thanks,
Allan
https://debug.datatables.net/ilevax
Thanks! That shows that the response from the server is:
So I don't understand why the debugger in the screenshot would be showing that there are four rows in the returned data.
Could you add
.Debug(true)
before the .Process(...)` method call please, and then run the debugger on it again to give me another trace?Thanks,
Allan
https://debug.datatables.net/ayapub
I'm using .net core 3.1
I fixed it.
It is important to instaal nuget package
Microsoft.AspNetCore.Mvc.NewtonsoftJson
And add the configuration lines in startup.cs. Like in the example. If you don't install this package, you won't get any errors (Framework 3.x) but it doesn't work.
Thanks for posting back - great to hear you've got it working.
Allan