How to call UseWebRoot in ASP.NET Core 3.0
ASP.NET Core 3.0 projects use the Generic Host, by default. In the project templates, it's configured like this:
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webHostBuilder =>
{
webHostBuilder.UseStartup<Startup>();
});
In the example above, webHostBuilder
is an implementation of IWebHostBuilder
, which still contains the UseWebRoot
extension method. That means you can call it as you did for 2.2, but it's just moved to inside the delegate passed in to ConfigureWebHostDefaults
shown above. Here's the complete example:
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webHostBuilder =>
{
webHostBuilder.UseStartup<Startup>();
webHostBuilder.UseWebRoot(@".\WebSite\wwwroot\");
});