Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- You need to add the annotation `[HttpPost]` to your Action and change the return type to `JsonResult`..
- public class WorkingController : Controller
- {
- // GET: Working
- public ActionResult Index()
- {
- return View();
- }
- [HttpPost]
- public JsonResult Save(WorkingModel model)
- {
- // All model properties are null here????
- return Json("Success");
- }
- }
- For more info have a look here: http://www.dontpaniclabs.com/blog/post/2013/02/27/posting-json-data-to-an-mvc-controller-via-ajax/
- EDIT:
- If you still are getting nulls inside of Save, change to:
- public class WorkingController : Controller
- {
- // GET: Working
- public ActionResult Index()
- {
- return View();
- }
- [HttpPost]
- public JsonResult Save([FromBody]WorkingModel model)
- {
- // All model properties are null here????
- return Json("Success");
- }
- }
- Sorry I can't fully remember when you have to use From Body and when you don't have to use, so try the first code first then try this
- EDIT:
- Also look into what `JSON.stringify` is producing... maybe its failing and sending null up.
- EDIT 2:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement