Jul 26, 2020

View is not updating values in Asp.Net MVC.

Sometime view is not updating values in Asp.Net MVC.

I have recently facing this issues and I thought let me write blog on this topic so it  will be helpful to others.

What was happen with me. I had developed a page couple of  year ago and it was working fine.

And few days ago I was working on that page and suddenly that page behavior was changed after POST action.

I was tried to save data and return View(model) and also before View(model) there was a some changes on model.

I had debug and check model is updating fine but value is not reflect on View (.cshtml) page.

So I had tried other alternative solutions but it was not work.

Finally got the solution and issue with ModelState.

 
ModelState.Clear();
return View(Model);

Before return View written ModelState.Clear() and resolved the issue.

Hope this solution help to you.

No comments:

Post a Comment