_ViewStart.cshtml
_ViewStart.cshtml is a Razor file that specifies code or common settings applied before views and pages in its directory scope are rendered.
Pro ASP.NET Core 7, Tenth Edition
A Razor view start file, typically _ViewStart.cshtml, specifies common settings such as the layout for views or pages in its scope.
- How it is used
- Sets a default layout for controller views or Razor Pages without repeating the Layout assignment in each file.
- How deep it goes
- Shows file placement, Layout assignment, scoped defaults, per-view overrides, and the malformed HTML caused by wrapping a complete document.
- Examples
- Uses Views/_ViewStart.cshtml, Pages/_ViewStart.cshtml, controller-specific layouts, and a full-document view that produces malformed HTML.
- What you can do after
- Operate/configure it to set shared layouts, override them for particular views, or disable them for complete HTML documents.
Read how Pro ASP.NET Core 7, Tenth Edition explains _ViewStart.cshtml →
ASP.NET Core in Action, 3e
_ViewStart.cshtml is a conventionally named Razor file containing code that executes before Razor views or pages in its directory and descendant directories are rendered.
- How it is used
- Sets shared Razor Page behavior, most commonly a default layout, before pages execute.
- How deep it goes
- Explains placement, inheritance, overrides, and execution boundaries, but does not detail the underlying Razor processing pipeline.
- Examples
- Demonstrates a default _Layout assignment and an area-specific layout for Identity Razor Pages.
- What you can do after
- Operate/configure Razor Pages with shared layouts and page-level layout exceptions.
Read how ASP.NET Core in Action, 3e explains _ViewStart.cshtml →
Related concepts
- layoutconfigures · A layout is the arrangement and positioning of content or interface elements within a page, screen, or other visual area.
- Razor layoutconfigures · A Razor layout is a reusable template that defines shared page structure around the content of individual Razor views.
- Pages folderpart of · The Pages folder is the conventional ASP.NET Core project directory that contains Razor Pages and their supporting Razor configuration files.
- Razor Pagesconfigures · Razor Pages is an ASP.NET Core page-focused programming model in which independently addressable pages combine Razor markup with request-handling logic.
- Razor syntaxconfigures · Razor syntax is a templating syntax that combines markup with embedded .NET code and directives to generate web content.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

