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: 737 ,

Oh hi there 👋
It’s nice to meet you.

Sign up to receive awesome content in your inbox.

We don’t spam! Read our privacy policy for more info.

Oh hi there 👋 It’s nice to meet you.

Sign up to receive awesome content in your inbox.

We don’t spam! Read our privacy policy for more info.

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Thank you so much!