我试着看了两个不同的真实项目,出于某种原因,只有其中一个项目能够按照预期的方式工作。在另一个'路线'标签不会突出显示成功匹配的路线和'观看'标签只显示没有。
我花了一些时间试图弄清楚什么是错误的,除了框架版本(工作者使用MVC4和另一个MVC5)之外,项目之间唯一的主要区别似乎是有问题的人使用自定义剃刀查看引擎和大多数路线都放入了区域。然而,在stackoverflow / google上搜索它是否可能是什么原因并没有给我什么。
那么,有关如何让我们一睹正常工作的想法,或者在哪里看看?
UPD
我检查了自定义视图引擎是否以某种方式干扰了Glimpse工作,事实上,当我评论出以下几行时,' Views'标签开始正常工作。但是,'路线' tab仍然没有告诉我在请求期间执行了哪些路由(仅列出它们)。
ViewEngines.Engines.Clear();
ViewEngines.Engines.Add(new CustomRazorViewEngine());
以下是CustomRazorViewEngine
的代码:
public class CustomRazorViewEngine : RazorViewEngine
{
public CustomRazorViewEngine() : base(null)
{
AreaViewLocationFormats = new[]
{
GetPath("Views/{2}/{1}/{0}.cshtml"),
GetPath("Views/{2}/{1}/{0}.vbhtml"),
GetPath("Views/{2}/Shared/{0}.cshtml"),
GetPath("Views/{2}/Shared/{0}.vbhtml")
};
AreaMasterLocationFormats = new[]
{
GetPath("Views/{2}/{1}/{0}.cshtml"),
GetPath("Views/{2}/{1}/{0}.vbhtml"),
GetPath("Views/{2}/Shared/{0}.cshtml"),
GetPath("Views/{2}/Shared/{0}.vbhtml")
};
AreaPartialViewLocationFormats = new[]
{
GetPath("Views/{2}/{1}/{0}.cshtml"),
GetPath("Views/{2}/{1}/{0}.vbhtml"),
GetPath("Views/{2}/Shared/{0}.cshtml"),
GetPath("Views/{2}/Shared/{0}.vbhtml")
};
ViewLocationFormats = new[]
{
GetPath("Views/{1}/{0}.cshtml"),
GetPath("Views/{1}/{0}.vbhtml"),
GetPath("Views/Shared/{0}.cshtml"),
GetPath("Views/Shared/{0}.vbhtml")
};
MasterLocationFormats = new[]
{
GetPath("Views/{1}/{0}.cshtml"),
GetPath("Views/{1}/{0}.vbhtml"),
GetPath("Views/Shared/{0}.cshtml"),
GetPath("Views/Shared/{0}.vbhtml")
};
PartialViewLocationFormats = new[]
{
GetPath("Views/{1}/{0}.cshtml"),
GetPath("Views/{1}/{0}.vbhtml"),
GetPath("Views/Shared/{0}.cshtml"),
GetPath("Views/Shared/{0}.vbhtml")
};
FileExtensions = new[]
{
"cshtml",
"vbhtml",
};
}
private string GetPath(string fileName)
{
var areaName = ConfigurationManager.AppSettings["areaName"];
if (string.IsNullOrEmpty(areaName))
{
return string.Format("~/{0}", fileName);
}
return string.Format("~/{0}/{1}", areaName, fileName);
}
}