IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    Avoid the cache data in ASP.NET MVC raizor page

    Winson发表于 2021-07-29 07:50:21
    love 0

    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:

    and this time will be working fine!

     1,600 total views

    The post Avoid the cache data in ASP.NET MVC raizor page appeared first on Coder Blog.



沪ICP备19023445号-2号
友情链接