0

solution screenshotI have several projects with MVC Views, 'TestProject' is the Website Content Directory, When I debug, I need build 'Address' project every time if I change cshtml file. I try to override RazorViewEngine, but it use Virtual Path, I can not use absolute path or relative path like '../../' to location where views/files are placed is out of the project's directory. It there a way that I can change cshtml file without build?

 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 is implement from VirtualPathProviderViewEngine, here is the same issue:How to use relative virtual path in custom razor view engine

xiaoquan
  • 31
  • 4

0 Answers0