Clearing View Engine in MVC breaks sitemap breadcrumb styles

In a web application MVC 5 that I develop to improve the effectiveness of the mechanisms I clear view and add only RazorViewEnginein the Global.asax.csvia ViewEngines.Engines.Clear();, and it breaks down the styles palettes mcc sitemap

Before

enter image description here

After

enter image description here

My partial sitemap view (SiteMapPathHelperModel.cshtml) looks like

@model MvcSiteMapProvider.Web.Html.Models.SiteMapPathHelperModel
@using System.Web.Mvc.Html
@using System.Linq
@using MvcSiteMapProvider.Web.Html.Models
<ol class="breadcrumb">
    @foreach (var node in Model)
    {
        if (node == Model.Last())
        {
            <li class="active">
                <strong>@Html.DisplayFor(m => node)</strong>
            </li>
        }
        else
        {
            <li>
                @if (node.Title == "Home")
                {
                    <a href="/"><i class="fa fa-lg fa-home"></i></a>

                }
                else
                {
                    @Html.DisplayFor(m => node)
                }
            </li>
        }
    }
</ol>

It seems somehow that it is returning to a different implementation than partial under views> shared> display templates

What could be the reason?

Edit

I missed the important information here, another developer did it at the bottom of Application_Start ()

ViewEngines.Engines.Add(new RazorViewEngine
{
     PartialViewLocationFormats = new string[]
     {
           "~/Areas/Shared/{0}.cshtml",
     }
});
+4
source share
3 answers

NightOwl Rowan

, "~/Views/Shared/{0}.cshtml" PartialViewLocationFormats

  ViewEngines.Engines.Add(new RazorViewEngine
            {
                PartialViewLocationFormats = new string[]
                {
                    "~/Areas/Shared/{0}.cshtml",
                    "~/Views/{1}/{0}.cshtml"
                    "~/Views/Shared/{0}.cshtml",
                }
            });
0

, , Application_Start.

public class MvcApplication : System.Web.HttpApplication
{
    protected void Application_Start()
    {
        ViewEngines.Engines.Clear();
        ViewEngines.Engines.Add(new RazorViewEngine());

        AreaRegistration.RegisterAllAreas();
        FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
        RouteConfig.RegisterRoutes(RouteTable.Routes);
        BundleConfig.RegisterBundles(BundleTable.Bundles);
    }
}

, MvcSiteMapProvider , /Views/Shared/DisplayTemplates/ . DLL, , , .

, Razor . , Application_Start ( ), Razor, , MvcSiteMapProvider.

ViewEngines.Engines.Clear();
ViewEngines.Engines.Insert(0, new RazorViewEngine());

, , - .

ViewEngines.Engines.RemoveAt(0);

MvcSiteMapProvider HTML-. , add , Razor MvcSiteMapProvider.

+1

MvcSiteMapProvider, ViewEngine. , .

MvcSiteMapProvider.Web.Mvc.MvcSiteMapProviderViewEngine() ViewEngines.

0

All Articles