2012-04-12 46 views
1

我在我的應用程序中添加了「cache.manifest」(此功能完美),從那以後,調試非常困難,因爲我必須始終清除緩存或修改cache.manifest版。僅在生產模式下應用緩存清單

我tryied加載清單與 「HttpContext.Current.IsDebuggingEnabled」 條件:

<!DOCTYPE HTML> 
    @if (HttpContext.Current.IsDebuggingEnabled) 
    { 
    <html> 
    } 
    else 
    { 
    <html manifest="/cache.manifest"> 
    } 

這不作品和Visual Studio給了我3個錯誤:

  • 塊丟失關閉}字符
  • html元素未關閉
  • 不能超過1 html元素。

有沒有人有想法?

謝謝!

回答

1

基於從 「sav931」 的答案,我終於找到了解決辦法:

<html @(HttpContext.Current.IsDebuggingEnabled ? "" : "manifest=cache.manifest")> 

無需在web.config中添加應用程序設置鍵,因爲已經有一個功能。 (HttpContext.Current.IsDebuggingEnabled)

此外,我發展時完全刪除了manfest屬性。

0

嘗試添加鍵像在web.config:

<add key="devMode" value="true"/> 

,現在在你的瀏覽補充一點:

<head @(Convert.ToBoolean(System.Web.Configuration.WebConfigurationManager.AppSettings["devMode"]) ? "manifest=/cache.manifest" : "manifest=devMode.manifest")> 

通過添加不存在,將禁用清單文件名緩存...

+0

謝謝!這個解決方案正在工作,我通過使用HttpContext.Current.IsDebuggingEnabled來調整它,使其更清潔。 – wizmagister 2012-05-03 20:12:07