Why does Razor _layout.cshtml have a leading underscore in file name?

前端 未结 5 766
傲寒
傲寒 2020-12-07 16:21

In the default ASP.NET MVC 3 project, layout & partial cshtml files start with an underscore

  • _viewstart
  • _Layout
5条回答
  •  失恋的感觉
    2020-12-07 16:36

    I dont use MVC, but with web pages which also uses the razor syntax, the _ prefix generally siginifies that the page is not meant to be accesssed by a user but by other pages or some code. If you try to navigate to a page that contains the _prefix, asp.net would prevent access to it. Thats why its used with layout pages and other such pages since they should not be accessed directly by a user.

    Something like the App_Code folder in asp.net

提交回复
热议问题