liveBook · Manning

_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.

How 2 Manning books explain it

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

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.