We run the following ContentRoot and WebRoot when starting our application from IIS.
ContentRoot: C:\MyApp\wwwroot
WebRoot: C:\MyApp\wwwroot\wwwroot
This is how we install ContentRootand WebRoot.
public class Startup
{
private readonly IHostingEnvironment _hostingEnv;
public Startup(IHostingEnvironment hostingEnv)
{
_hostingEnv = hostingEnv;
}
public void Configure(IApplicationBuilder app)
{
app.Run(context =>
{
context.Response.WriteAsync(_hostingEnv.ContentRootPath + "\r\n");
return context.Response.WriteAsync(_hostingEnv.WebRootPath + "\r\n");
});
}
public static void Main(string[] args)
{
var contentRoot = Directory.GetCurrentDirectory();
var webRoot = Path.Combine(contentRoot, "wwwroot");
var host = new WebHostBuilder()
.UseKestrel()
.UseIISPlatformHandlerUrl()
.UseContentRoot(contentRoot)
.UseWebRoot(webRoot)
.UseStartup<Startup>()
.Build();
host.Run();
}
}
From intellisense, I see that ...
- ContentRootPath contains application content files.
- WebRootPath contains content files for web content.
How to make test output look like this:
ContentRoot: C:\MyApp\
WebRoot: C:\MyApp\wwwroot\
source
share