MVC 3 The View is not being refreshed after model submit
You need to remove the value from the ModelState
if you want to modify it in a post/get:
[HttpPost]
public ViewResult EditUserData(UserData model)
{
ModelState.Remove("Name");
model.Name = "ipsum";
return View("~/Views/UserDetails.cshtml", model);
}
This is the built in MVC behavoir: all the Html.Helpers
prefers the values in the ModelState
collection over the actual model values.
There is a good article about this here: ASP.NET MVC Postbacks and HtmlHelper Controls ignoring Model Changes.
This is by design. MVC is assuming that you want to show what the user initially submitted when processing a post action. See this related stack overflow post.