How to pass in ID with Html.BeginForm()?

Matt’s should work fine. If you are still passing in FormMethod.Post, though, you need to do it like this:

Html.BeginForm("action","controller", new { Id = 12345 }, FormMethod.Post);

Reversing the third and fourth parameters will result in the Id being treated as an attribute instead of a route value.

Leave a Comment