rstaib / jquery-bootgrid

Nice, sleek and intuitive. A grid control especially designed for bootstrap.
http://www.jquery-bootgrid.com
MIT License
973 stars 364 forks source link

Bootgrid and .Net Core Ajax Posting not working ... #421

Open temilson opened 5 years ago

temilson commented 5 years ago

I've used bootgrid on numerous projects to date and love it!

However I'm trying to use in now on a new .Net Core project and whenever I try to initialize the grid using ajax, I'm getting a 415 'Unsupported Media Type' error.

I'm assuming it has something to do with this: https://andrewlock.net/model-binding-json-posts-in-asp-net-core/

Here is my JS: $("#grid-sentinels-list").bootgrid({ searchSettings: { delay: 100, characters: 3 }, ajax: true, url: "/projects/allsentinels", } }).on("loaded.rs.jquery.bootgrid", function () { });

Here is my controller: [HttpPost] [ValidateAntiForgeryToken] public ActionResult AllSentinels([FromServices]MessagingContext _context,bootGridObject obj) { //Code goes here but of course is never hit due to 415 error. }

Here is my bootGridObject: public class bootGridObject { public int current { get; set; } public int rowCount { get; set; } public string searchPhrase { get; set; } public string id { get; set; } }

However so far I haven't been able to get it working.

Any thoughts?