Resolve POST method not Triggered in a MVC App

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:

  1. Check your action in the controller is decorated with [HttpPost].
  2. Make sure button that fires POST method is having type as submit.
  3. Keep your submit button inside form tag or @Html.BeginForm()
  4. 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;

    }

    }

     

  5. Use Fiddler or IE 9 Developer Tools [Network capture] to check POST request status.
Ebook Download
View all
Learn
View all