简体   繁体   中英

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?

.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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM