Disable OutputCache on Development System

前端 未结 2 1968
醉话见心
醉话见心 2021-02-07 11:21

I use OutputCache in an ASP.net MVC application. As developing with an active OutputCache is not very pleasant I want to disable the OutputCache on the Development Systems (loca

相关标签:
2条回答
  • 2021-02-07 11:46

    The outputcache in ASP.NET can be enabled and disabled using

    For iis versions < 7.0

    <system.web>
        <caching>
            <outputCache enableOutputCache="false" />
        </caching>
    </system.web>
    

    For iis versions >= 7.0

    <system.webServer>
        <caching enabled="false" />
    </system.webServer>
    

    N.B. I usually use both, better safe than having a sore foot, and use a config transform to make sure that the caching is enabled for different configurations on publish. In my solution a configuration corresponds 1 on 1 with an environment

    Another technique is to use pragmas to enable pieces of code to compile or not compile based on i.e. the DEBUG conditional compilation symbol:

    #if DEBUG
        [OutputCache]
    #endif
    
    0 讨论(0)
  • 2021-02-07 11:54

    It's an old one but...

    set this in your web.config under system.web

    <caching>
      <outputCache enableOutputCache="false" />
    </caching>
    
    0 讨论(0)
提交回复
热议问题