Web API self host - bind on all network interfaces

青春壹個敷衍的年華 提交于 2019-11-30 05:55:28

Just change the base address like this

        var baseAddress = string.Format("http://*:9000/"); 
        using (WebApp.Start<Startup> (baseAddress)) 
        {
            Console.WriteLine("Server started");
            Thread.Sleep(1000000);
        }

And it should bind correctlly to all interfaces.

Daniel Müller

bind it using :-

var baseAddress = string.Format("http://localhost:+:9000/"); 

If you get access exceptions, Please DO NOT start Visual Studio as admin user. Add an URL reservation instead. Start a command console window as administrator and execute:

netsh
netsh> http add urlacl url="http://+:9000/" sddl=D:(A;;GX;;;S-1-1-0)

The SDDL translates to "all users" from your current domain / machine.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!