ASP.NET MVC’s HTML helpers first look for a value in the request parameters, then look for the value in the viewmodel.
So, for example, if my request URL is /MyPage?foo=999
and my viewmodel has a property named “Foo” (or “foo”, it’s not case sensitive), the value output by HiddenFor(x => x.Foo)
is going to be “999”, even if I set it my viewmodel property’s value to something else in my controller action.
(This was causing a colleague a lot of head scratching yesterday, so I thought I’d pass my explanation along here.)