Is it possible to configure a different folder to replace wwwroot
in ASP.NET Core? And, if yes, how? And are there any side effects to this change?
The only config that currently includes wwwroot
in the entire project is found in project.json
as seen in the code below; but replacing the value with the name of the new folder is not enough for the static file (ex: index.html
) to be read.
"publishOptions": {
"include": [
"wwwroot",
"web.config"
]
},
Is it possible to configure a different folder to replace wwwroot in ASP.NET Core?
Yes. Add a UseWebRoot
call in your 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?
Here are three that I can think of:
lib
folder in wwwroot
. I'm not certain if this is configurable.bundleconfig.json
to look at the new directory.include
portion in project.json
to include your new directory in the publish output.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With