Failed to bind to address (already in use) error with Visual Studio Mac API

后端 未结 7 1764
隐瞒了意图╮
隐瞒了意图╮ 2021-01-21 03:34

I\'m attempting to create a Web API via .Net Core. I\'m just using the boilerplate ValuesController as a Hello World. When I run the project, I get the following error:

7条回答
  •  不思量自难忘°
    2021-01-21 04:17

    I was able to at least temporarily solve this issue by implementing a workaround provided by Bill Boga on his site here: https://www.billbogaiv.com/posts/setting-aspnet-host-address-in-net-core-2

    The key for my project was to add .UseUrls(urls: "http://localhost:10000") in the BuildWebHost function. Like so:

    using Microsoft.AspNetCore;
    using Microsoft.AspNetCore.Hosting;
    using OrchardCore.Logging;
    using OrchardCore.Modules;
    
    namespace ShiftBrandSite
    {
        public class Program
        {
            public static void Main(string[] args)
            {
                BuildWebHost(args).Run();
            }
    
            public static IWebHost BuildWebHost(string[] args) =>
                WebHost.CreateDefaultBuilder(args)
                    .UseNLogWeb()
                    .UseStartup()
                    .UseUrls(urls: "http://localhost:10000") // <-- localhost urls
                    .Build();
        }
    }
    

    Hope this helps!

提交回复
热议问题