solution screenshot我有多个具有MVC视图的项目,“ TestProject”是网站内容目录, 调试时,如果更改cshtml文件,则每次都需要构建“地址”项目。 我尝试覆盖RazorViewEngine,但是它使用虚拟路径,我不能使用绝对路径或相对路径(如“ ../../”)将视图/文件放置在项目目录之外。 有没有一种方法可以更改cshtml文件而不进行构建?
public class DebugRazor: RazorViewEngine
{
public DebugRazor(string relativePath)
{
base.ViewLocationFormats = new[]
{
"../" + relativePath + "/Views/{1}/{0}.cshtml",
"../" + relativePath + "/Views/{1}/{0}.vbhtml",
"../" + relativePath + "/Views/Shared/{0}.cshtml",
"../" + relativePath + "/Views/Shared/{0}.vbhtml"
};
}
}
RazorViewEngine是从VirtualPathProviderViewEngine实现的,这是相同的问题:How to use relative virtual path in custom razor view engine