Skip to main content
I can't count!
Source Link
Will Ray
  • 10.8k
  • 3
  • 47
  • 63

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 twothree that I can think of:

  1. The Bower package manager will not work properly, as it looks for a lib folder in wwwroot. I'm not certain if this is configurable.
  2. You will need to fix bundleconfig.json to look at the new directory.
  3. You will need to update the include portion in project.json to include your new directory in the publish output.

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 two that I can think of:

  1. The Bower package manager will not work properly, as it looks for a lib folder in wwwroot. I'm not certain if this is configurable.
  2. You will need to fix bundleconfig.json to look at the new directory.
  3. You will need to update the include portion in project.json to include your new directory in the publish output.

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:

  1. The Bower package manager will not work properly, as it looks for a lib folder in wwwroot. I'm not certain if this is configurable.
  2. You will need to fix bundleconfig.json to look at the new directory.
  3. You will need to update the include portion in project.json to include your new directory in the publish output.
Source Link
Will Ray
  • 10.8k
  • 3
  • 47
  • 63

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 two that I can think of:

  1. The Bower package manager will not work properly, as it looks for a lib folder in wwwroot. I'm not certain if this is configurable.
  2. You will need to fix bundleconfig.json to look at the new directory.
  3. You will need to update the include portion in project.json to include your new directory in the publish output.