There is a strictly typed TestView view. The view model class contains an ID and a few more properties. Up to the transfer of the ViewModel to the presentation, the ID has one value (5 for example), but as a result, a field with a different value (10) is generated. I can not understand what's wrong.

  • I do not rummage in ASP.NET, but in any case, there is no code in your post, but it should be. - Vladimir Gordeev
  • The point here is not even in the code. More precisely, not in my, and in the helper code. Mine looks like this: Html.HiddenFor (model => model.ID), where ID == 5, debugger passed - the same. But as a result, generating is not what you need <input id = "ID" name = "ID" type = "hidden" value = "10" /> <script> alert ("Vulnerability detected"); </ script> - Andrey Ashgaliyev
  • In one of the many Best Practices for ASP.NET MVC, I read something like the following:> Use HTML where possibleSpecter

1 answer 1

Here is a description of the problem.

http://blogs.msdn.com/b/simonince/archive/2010/05/05/asp-net-mvc-s-html-helpers-render-the-wrong-value.aspx

You need to do ModelState.Clear () ;