Sometimes, our POST method/action wrote in MVC application won't be fired. We will look into steps to be followed for fixing the issue:
- Check your action in the controller is decorated with [HttpPost].
- Make sure button that fires POST method is having type as submit.
- Keep your submit button inside form tag or @Html.BeginForm()
- verify, all your client validations are
passed. If a client validation fails, it won't fire POST action. To confirm
it, disable client validation by adding below code to the view:
@(ViewContext.ClientValidationEnabled = true)
Check whether any values within your ModelState have errors or not using below code:
foreach(var item in ModelState.Values)
{
foreach (var error in item.Errors)
{
var errorMessage = error.ErrorMessage;
var exception = error.Exception;
}
}
- Use Fiddler or IE 9 Developer Tools
[Network capture] to check POST request status.

Emmanuel GleizerPosted Aug 11, 2020, 4:58 AM
How can we "Check whether any values within your ModelState" if the method is *not* Triggered in a MVC ?