是否可以配置不同的文件夹来替换 ASP.NET Core 中的 wwwroot?如果是,这种变化如何以及是否有任何副作用?
当前唯一包含 wwwroot
的配置在整个项目中找到project.json
如下面的代码所示;但是用新文件夹的名称替换值不足以读取静态文件(例如: index.html
)。
"publishOptions": {
"include": [
"wwwroot",
"web.config"
]
},
最佳答案
Is it possible to configure a different folder to replace wwwroot in ASP.NET Core?
是的。添加
UseWebRoot
调用您的 Program
类(class):public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseKestrel()
.UseWebRoot("myroot") // name it whatever you want
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.Build();
host.Run();
}
are there any side effects to this change?
以下是我能想到的三个:
lib
文件夹在 wwwroot
.我不确定这是否可以配置。 bundleconfig.json
查看新目录。 include
project.json
中的部分将您的新目录包含在发布输出中。 关于asp.net-core - 如何在 ASP.NET Core 中为 wwwroot 配置替代文件夹?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40535388/