Я искал немного, но не нашел ничего полезного. Моя древовидная структура выглядит следующим образом:
![enter image description here](https://i.stack.imgur.com/N7VEf.png)
Однако моя проблема заключается в том, что я не могу вызвать Html.Partial(...)
в любом из CMS > Views
, потому что я получить ошибку:
'HtmlHelper ' не содержит определения для 'Частичное'
Я не уверен, почему, я пытался возиться с некоторые web.config
вещи, но ничего не работает.
Маршрутизация
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.LowercaseUrls = true;
routes.MapRoute(
name: "CMSRoute",
url: "initium/{action}/{id}",
defaults: new { controller = "CMS", action = "Login", Id = UrlParameter.Optional },
new[] { "Initium" }
);
routes.MapRoute(
name: "WebsiteRoute",
url: "{*Url}",
defaults: new { controller = "CMS", action = "Page", Url = "home" },
new[] { "Initium" }
);
}
Global.asax.cs
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
RouteConfig.RegisterRoutes(RouteTable.Routes);
RazorViewEngine objRazorEngine = ViewEngines.Engines.OfType<RazorViewEngine>().First();
objRazorEngine.ViewLocationFormats = new string[]
{
"~/CMS/Views/{0}.cshtml",
"~/CMS/Views/{1}/{0}.cshtml",
"~/CMS/Views/Shared/{0}.cshtml",
"~/Views/{0}.cshtml",
"~/Views/{1}/{0}.cshtml",
"~/Views/Shared/{0}.cshtml"
};
objRazorEngine.PartialViewLocationFormats = new string[]
{
"~/CMS/Views/Partials/{0}.cshtml",
"~/CMS/Views/{1}/Partials/{0}.cshtml",
"~/Views/Partials/{0}.cshtml",
"~/Views/{1}/Partials/{0}.cshtml"
};
}