Supporting custom view locations in ASP.Net MVC
I see this discussion indicates that Resharper (I am using 6.1) has support to detect when the default location of views is changed in MVC. But I can't seem to get it to work.http://devnet.jetbrains.net/message/5307956#5307956Here is code that I have in my Global.aspx.cs file: var viewLocationFormats = new[] { "~/Controllers/{1}/Views/{0}.cshtml", "~/Views/{1}/{0}.cshtml", "~/Views/Shared/{0}.cshtml" }; ViewEngines.Engines.Clear(); var razorViewEngine = new RazorViewEngine(); razorViewEngine.ViewLocationFormats = viewLocationFormats; razorViewEngine.PartialViewLocationFormats = viewLocationFormats; ViewEngines.Engines.Add(razorViewEngine); Is there anything or different I should be doing?Thanks,Rob Cannon
Please sign in to leave a comment.
Rob, ReSharper currently can detect only direct string literals assigment.
Remove variable and assign constants directly.
I'm having a simular problem with a custom view engine, when I add my ViewLocationFormats in my custom view engine constructor
public XSLTViewEngine()
{
ViewLocationFormats = new []{"~/Views/{1}/{0}.xslt","~/Views/Shared/{0}.xslt"};
PartialViewLocationFormats = new[] { "~/Views/{1}/{0}.xslt", "~/Views/Shared/{0}.xslt" };
}
resharper is no longer able to resolve razer and webforms views