- Hands-On Full:Stack Web Development with ASP.NET Core
- Tamir Dresher Amir Zuker Shay Friedman
- 193字
- 2021-06-10 19:37:23
The content root and web root folders
ASP.NET Core defines two types of folders:
- Content root: This is the root directory of the application. Any files outside this directory will not take part in the frontend application.
- Web root: This is where static files are located.
By default, the content root is the root folder of the application, and the web root is the <content root>/wwwroot folder.
The web root folder is not exposed to the end user by default. Making it available to end users is described later in this chapter, under Setting the server to serve static files.
In large applications, the content root path might need to be changed. To do so, open the Program.cs file, locate the CreateWebHostBuilder static method, and add the following marked line to it:
WebHost.CreateDefaultBuilder(args)
.UseContentRoot(Path.Combine(Directory.GetCurrentDirectory(),
"/client"))
.UseStartup<Startup>()
.Build();
In this example, we're setting the path of the content root folder to <project root>/client.
In addition, the wwwroot folder name might not fit all scenarios. In order to change it, open the Program.cs file, find the BuildWebHost, and change it as follows:
WebHost.CreateDefaultBuilder(args)
.UseContentRoot(Directory.GetCurrentDirectory())
.UseWebRoot("assets")
.UseStartup<Startup>()
.Build();
The highlighted line changes the web root path to <content root>/assets.
推薦閱讀
- Mastering Node.js(Second Edition)
- 網(wǎng)絡(luò)故障現(xiàn)場(chǎng)處理實(shí)踐(第4版)
- 智慧城市中的移動(dòng)互聯(lián)網(wǎng)技術(shù)
- 數(shù)字通信同步技術(shù)的MATLAB與FPGA實(shí)現(xiàn):Altera/Verilog版(第2版)
- Metasploit Penetration Testing Cookbook
- Spring 5.0 Projects
- 新手易學(xué):新手學(xué)淘寶開店
- Working with Legacy Systems
- 物聯(lián)網(wǎng)與智能家居
- Learning Node.js Development
- 園區(qū)網(wǎng)絡(luò)架構(gòu)與技術(shù)
- 互聯(lián)網(wǎng)安全的40個(gè)智慧洞見(2016)
- 一本書讀懂TCP/IP
- bash網(wǎng)絡(luò)安全運(yùn)維
- OSPF協(xié)議原理與功能拓展