.NET MVC中ViewLocationCache视图缓存问题

通过HttpContext获取视图缓存位置

string cachePath = this.ViewLocationCache.GetViewLocation(controllerContext.HttpContext, cacheKey);

如果在调试模式下cachePath 始终为NULL。

查看MVC 源码后发现

if (HttpContext.Current == null || HttpContext.Current.IsDebuggingEnabled)
{
   ViewLocationCache = DefaultViewLocationCache.Null;
}

在调试模式下 ViewLocationCache = DefaultViewLocationCache.Null; 所以cachePath 始终为NULL。

 

 

 

posted on 2016-08-30 11:20  一笑而过。  阅读(282)  评论(0编辑  收藏  举报

导航