I have some problem with adding subfolder to /Views/Shared in project. Here is my current structure:
/Views/Shared/AreasNavs/{0}.cshtml
From the web I found some solutions:
services.Configure<RazorViewEngineOptions>(o =>
{
o.ViewLocationFormats.Add("/Views/Shared/AreasNavs/{0}" + RazorViewEngine.ViewExtension);
});
...and this solution from Adding sub-directory to “View/Shared” folder in ASP.Net MVC and calling the view
services.AddMvc()
.AddRazorOptions(opt => {
opt.ViewLocationFormats.Add("/Views/{1}/Partials/{0}.cshtml");
opt.ViewLocationFormats.Add("/Views/Shared/Partials/{0}.cshtml");
});
but nothing is work.
Update. this problem is related to the appeal from the Area
Have you any idea?
Thanks!
I`ve just run into the same problem. The issue is related to area registration. Instead of
services.Configure<RazorViewEngineOptions>(o =>
{
o.ViewLocationFormats.Add("/Views/Shared/AreasNavs/{0}" + RazorViewEngine.ViewExtension);
});
use view location for areas
services.Configure<RazorViewEngineOptions>(o =>
{
o.AreaViewLocationFormats.Add("/Views/Shared/AreasNavs/{0}" + RazorViewEngine.ViewExtension);
});