Avoid the cache data in ASP.NET MVC raizor page

The MVC view data cache is good but sometime we just want to reset the page’s value with binding Model, and you will find the value can not be reset, such link in a search form with the criteria.

For example, you want to reset all the criteria fields to default (not empty) as below

but you will find that’s not working, the date values are still keep as the user’s input values, the problem is the Views page will auto cache the binding Model value, so you need to use ModelState.Clear(); to clear the model state when you reset the model value:

Do you want to be a good trading in cTrader?   >> TRY IT! <<

and this time will be working fine!

Loading

Views: 2
Total Views: 236 ,

Leave a Reply

Your email address will not be published. Required fields are marked *