通过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。