A Razor directive is an @-prefixed statement that changes how a Razor file is parsed or compiled. In Razor Pages, @page makes a .cshtml file routable; without it, the framework ignores the file for most purposes. section 17.2.1
Common directives connect a Razor view to its page model or make names available:
- @page marks the file as a Razor Page. section 17.2.1
- @model identifies the PageModel type used for binding and page-handler execution; it is technically optional. section 17.2.1
- @using imports a namespace so its objects are available in the view. section 17.2.1
A routable Razor Page
Place these directives at the top of a .cshtml file:\n\n@page\n@model ToDoItemModel\n\nThe framework can route requests to the page and associate it with ToDoItemModel. It then binds marked properties and runs the appropriate handler. section 17.2.1
@page @model ToDoItemModel
Use the compact listing to recognize the two directives that establish a Razor Page and its PageModel. section 17.2.1
Shared directives belong in _ViewImports.cshtml, which applies them to views and subfolders. Use it for directives such as @using or @addTagHelper, not arbitrary C#. Use _ViewStart.cshtml for shared Razor code such as assigning a default Layout. section 17.4.4


