仅在生产模式下应用缓存清单

仅在生产模式下应用缓存清单

问题描述:

我在我的应用程序中添加了“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元素。

有没有人有想法?

谢谢!

基于从 “sav931” 的答案,我终于找到了解决办法:

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

无需在web.config中添加应用程序设置键,因为已经有一个功能。 (HttpContext.Current.IsDebuggingEnabled)

此外,我发展时完全删除了manfest属性。

尝试添加键像在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