简体   繁体   English

如何重命名ASP.NET 5 Web项目中用作Web根的“ wwwroot”文件夹

[英]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 . 我想将ASP.NET 5项目中的Web根文件夹重命名为wwwroot以外的名称。 When I manually rename that folder, the project no longer recognizes it as the web root folder. 当我手动重命名该文件夹时,项目不再将其识别为Web根文件夹。 The project properties page does not allow the web root to be modified. 项目属性页面不允许修改Web根目录。 Is there any way to rename and/or reassign the web root folder in ASP.NET 5 web projects? 有什么方法可以在ASP.NET 5 Web项目中重命名和/或重新分配Web根文件夹?

The docs don't quite explain your desired process. 该文档并没有完全解释您所需的过程。 They assume someone wouldn't rename wwwroot but would just use another folder. 他们假设某人不会重命名wwwroot而只会使用另一个文件夹。 As you mentioned in comments, you must use hosting.json , not project.json as was previously suggested. 正如您在评论中提到的那样,您必须使用hosting.json ,而不是以前建议的project.json However, the order of operations matters if you want to rename wwwroot rather than just use another folder. 但是,如果要重命名wwwroot而不是仅使用另一个文件夹,则操作顺序很重要。 To get the desired result: 要获得理想的结果:

  1. Create the test folder (instead of renaming wwwroot folder) 创建test文件夹(而不是重命名wwwroot文件夹)
  2. Add the hosting.json file with the webroot entry pointing to the test folder. 添加hosting.json文件,并将其webroot条目指向test文件夹。
  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 . 如果VS没有重新启动/重新打开项目,只需重新启动VS,您应该会看到test文件夹现在显示为webroot

At that point, you can move contents from wwwroot to test if that hasn't already happened. 那时,您可以将内容从wwwroot移到test是否还没有发生。

You can manually rename the folder but you would need to update/create the hosting.json to specify the name of web root folder. 您可以手动重命名该文件夹,但是需要更新/创建hosting.json以指定Web根文件夹的名称。

{
    "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 即: 在这里检查

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将“react js”构建到我的“asp.net core web api”的 wwwroot 文件夹时出现路由问题 - Routing problem when building "react js" to wwwroot folder of my "asp.net core web api" “wwwroot”文件夹中的某些文件未在 ASP.NET 核心 web 部署中发布 - Some files in "wwwroot" folder are not published in ASP.NET Core web deploy 从 Asp.net 内核 Web API 3.1 “wwwroot”之外的文件夹加载图像 - Loading Image from Asp.net core Web API 3.1 Folder outside of “wwwroot” 更新到 Asp.Net Core 3 的 Identity 项目提供了 wwwroot 文件夹 - Identity project updated to Asp.Net Core 3 gives wwwroot folder 如何在没有 WWWROOT 的情况下使用 ASP.NET 在我的 Web 应用程序中提供 html 文件? - How do I serve an html file in my Web App with ASP.NET without the WWWROOT? 在ASP.NET 4.5项目中使用wwwroot文件夹(ASP.NET Core样式) - Using a wwwroot folder (ASP.NET Core style) in ASP.NET 4.5 project 如何将第三方dll从bin文件夹移动到ASP.NET Web Forms项目中的另一个文件夹? - How to move third party dlls from bin folder to another folder in ASP.NET Web Forms project? ASP.Net 上传图片到 wwwroot 文件夹 - ASP.Net uploading image to wwwroot folder ASP.NET Web窗体:如何遍历项目/服务器文件夹中的文件 - ASP.NET Web Forms: How to traverse the files in a project/server folder 如何确定ASP.NET Web解决方案使用哪些表? - How to determine which tables are used by ASP.NET web solution?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM