pantonis
pantonis

Reputation: 6467

Asp.Net Core 2.2 UseUrls is ignored

I have the following code in my Asp.Net Core 2.2

public class Program
{
    public static void Main(string[] args)
    {
        var urls = new string[] { "https://localhost:3045" };
        CreateWebHostBuilder(args, urls).Build().Run();
    }

    public static IWebHostBuilder CreateWebHostBuilder(string[] args, string[] bindingUrls) =>
        WebHost.CreateDefaultBuilder(args)
            .ConfigureServices(services => services.AddAutofac())
            .ConfigureKestrel(opt =>
            {
                opt.AddServerHeader = false;
            })
            .UseContentRoot(Directory.GetCurrentDirectory())
            .UseIISIntegration()
            .UseUrls(bindingUrls)
            .UseStartup<Startup>();
}

However when I debug the site is launched on https://localhost:44326/ why is used in launchSettings.json Why is that happening?

Upvotes: 2

Views: 2021

Answers (1)

Anton Toshik
Anton Toshik

Reputation: 2909

.UseUrls(bindingUrls) will configure Kestrel url.

dotnet core always sits in Kestrel behind IIS/IIS Express as a proxy. The url you get is the configuration for your IIS Express.

This url can be changed in your project settings or launchSettings.json

If you would like to just run on Kestrel user the cli command dotnet run or dotnet watch run

Upvotes: 3

Related Questions