Underscored view in ASP.NET MVC
When I create a new ASP.NET MVC project two files with underscore are created: Views/_Vie开发者_开发技巧wStart.cshtml and Views/Shared/_Layout.cshtml. What does underscore mean?
Mike Brind has put this nicely in the question Why does Razor _layout.cshtml have a leading underscore in file name?:
Since layout pages in Web Pages are not intended to be served directly, they are prefixed with the underscore. And the Web Pages framework has been configured not to allow files with leading underscores in their names from being requested directly.
In MVC, I use this convention to name partial views with a leading underscore to differentiate between full views and partial ones.
It is a naming convention for "included" views (master pages, partial views etc or any views that would not render stand-alone) - nothing magical, just a convention - although I seem to remember the underscore may be significant in WebPages, but certainly not in MVC.
精彩评论