aspdotnet_contentroot.md - brainchildservices/curriculum GitHub Wiki
-
The content root is the base path for:
- The executable hosting the app (.exe).
- Compiled assemblies that make up the app (.dll).
- Content files used by the app, such as:
- Razor files (.cshtml, .razor)
- Configuration files (.json, .xml)
- Data files (.db)
- The Web root, typically the wwwroot folder.
-
During development, the content root defaults to the project's root directory.
-
This directory is also the base path for both the app's content files and the Web root.
-
Specify a different content root by setting its path when building the host.
-
The IHostEnvironment.ContentRootPath property determines where the host begins searching for content files. If the path doesn't exist, the host fails to start.
- Key: contentRoot
- Type: string
- Default: The folder where the app assembly resides.
- Environment variable: <PREFIX_>CONTENTROOT
-
To set this value, use the environment variable or call UseContentRoot on IHostBuilder:
Host.CreateDefaultBuilder(args) .UseContentRoot("c:\\content-root") //...