11

My application uses self-hosting feature of ASP.NET Web API. NuGet package name I use is Microsoft.AspNet.WebApi.SelfHost. I used following example as a base.

Following code works for me to launch host on ipv4 localhost endpoint:

WebApp.Start<Startup>("http://127.0.0.1:43666");

What do I enter if I want to specify ipv6 address? "http://[::1]:43666" does not work. Exception thrown is [reformatted]:

System.Net.HttpListenerException: The network location cannot be reached. For information
   ..about network troubleshooting, see Windows Help
at System.Net.HttpListener.AddAllPrefixes()
at System.Net.HttpListener.Start()
at Microsoft.Owin.Host.HttpListener.OwinHttpListener.Start(HttpListener listener, 
   ..Func`2 appFunc, IList`1 addresses, IDictionary`2 capabilities, Func`2 loggerFactory)
at Microsoft.Owin.Host.HttpListener.OwinServerFactory.Create(Func`2 app, 
   ..IDictionary`2 properties)

Judging by my inspection of code in reflector, the HttpAddUrlToUrlGroup function returned error code 1232

4

2 回答 2

10

我没有找到解决方案,但是以下是一种解决方法,尽管它会在所有地址上启动服务器,包括非本地和 ipv4:

WebApp.Start<Startup>("http://+:43666");

由于这个问题没有引起任何兴趣,我将关闭它

于 2013-10-14T15:03:31.707 回答
0

有同样的问题,它似乎是运行服务的帐户。需要确保它在 NetworkService 下运行 - localhost 和其他 URL 变体都应该可以工作:)

于 2016-07-21T14:38:47.497 回答