Search code examples
c#cssasp.net-corelayout

ASP.NET Core layout is not loaded in my area


My layout name is = _DefaultLayout.

Controller:

enter image description here

_ViewStart:

enter image description here

Index.cshtml:

enter image description here

The CSS is not loaded in this page, but on another page it is loaded.

Please help my to fix this problem

Thanks


Solution

  • Seem like typo problem. The suffix for layout code is predefined. Therefore, change _DefaultLayout.csshtml to _DefaultLayout.cshtml.

    Then in the _ViewStart.cshtml you can write:

    @{
        Layout = "~/Views/Shared/_DefaultLayout.cshtml";
    }
    

    And check that Build Action property of the _DefaultLayout.cshtml file is set to Content.

    For additional information see: Layout in ASP.NET Core