I have a multi-step setup process where I would like to pass query string arguments appended to the URL only if they are relevant.
http://localhost:6618/Account/Prof
args was generated by a filter, and is a RouteValueDictionary
That's the key point here. In this case make sure you are using the correct overload of the BeginForm method:
@using(Html.BeginForm(
"Profile",
"Account",
args,
FormMethod.Post,
new RouteValueDictionary(new { @class = "mainForm" })
))
{
...
}
Notice the last argument? It must be an IDictionary
for this to work.
In your example it is this overload that gets picked up. But since you are passing a RouteValueDictionary
for the routeValues parameter instead of an anonymous object it gets messed up.
So, you should either have both routeValues and htmlAttributes as dictionaries or both as anonymous objects.