简体   繁体   中英

How to rename “wwwroot” folder used as web root in ASP.NET 5 web project

I would like to rename the web root folder in my ASP.NET 5 project to something other than wwwroot . When I manually rename that folder, the project no longer recognizes it as the web root folder. The project properties page does not allow the web root to be modified. Is there any way to rename and/or reassign the web root folder in ASP.NET 5 web projects?

The docs don't quite explain your desired process. They assume someone wouldn't rename wwwroot but would just use another folder. As you mentioned in comments, you must use hosting.json , not project.json as was previously suggested. However, the order of operations matters if you want to rename wwwroot rather than just use another folder. To get the desired result:

  1. Create the test folder (instead of renaming wwwroot folder)
  2. Add the hosting.json file with the webroot entry pointing to the test folder.
  3. If VS doesn't restart/reopen the project, just restart VS and you should see the test folder now show up as the webroot .

At that point, you can move contents from wwwroot to test if that hasn't already happened.

You can manually rename the folder but you would need to update/create the hosting.json to specify the name of web root folder.

{
    "webroot": "wwwroot"
}

beware: there are changes in progress between releases that are not reflected in the official docs at the time of this post yet. ie: check here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM