MVC: submit button name / value is not sent in post data

In MVC, we have multiple forms that can be placed with multiple buttons. We use the name of the button in our POST action for the controller to check which button was clicked and what logic to execute.

It's fine! But ... in some cases, the submit button is not published. We see all the post data in our exception monitoring system, and in these cases there is no submit button and the Controller GET action is performed instead of one of the POST actions.

Anyone have an idea how this is possible? This happens using different browsers and different forms, so no logic can be found :(

+3


source to share


1 answer


There is a similar question here. You must include all your submit buttons with sismilar name. For example:

<input type="submit" name="submitButton" value="Send" />
<input type="submit" name="submitButton" value="Cancel" />

      



So in action, you can get the value from the collection from it.

0


source







All Articles