2011-11-30 94 views
0

在我的web.config,<system.web>下,我有:ASP.NET web配置文件?

<caching> 
    <outputCacheSettings> 
    <outputCacheProfiles> 
     <add name="Cache60Seconds" 
      location="ServerAndClient" 
      duration="60" 
      varyByParam="" 
     /> 
    </outputCacheProfiles> 
    </outputCacheSettings> 
</caching> 

在此的.config的調試版本,Web.Debug.config,我想配置文件 「Cache60Seconds」 的duration變爲0。

換句話說,當我開發時,我想讓「Cache60Seconds」的持續時間爲0,所以它永遠不會緩存,並且當我釋放產品時,我希望持續時間變爲60秒。我該怎麼做呢?

+0

請檢查此鏈接是否真的有幫助http://frejnorling.wordpress.com/2011/05/15/automatically-create-different-web-config-files-for-debug-and-release-builds-in -visual-studio-2010/http://www.hanselman.com/blog/WebDeploymentMadeAwesomeIfYoureUsingXCopyYoureDoingItWrong.aspx –

回答

1

你在中途有Web Config Transformations但是你應該設置你的Web.Config文件以使你有典型的開發環境設置(例如,將緩存持續時間設置爲0)並且在你的Web.Release.Config中設置合適的緩存您發佈環境的持續時間。

+0

+1請注意,這是Visual Studio 2010的一項功能,並且* not * IIS。轉換作爲打包過程的一部分運行......它們不會自動應用到任何位置,並且web.release.config文件本身不會由IIS加載 –