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.
我的应用程序使用ASP.NET Web API的自托管功能。我使用的NuGet包名是Microsoft.AspNet.WebApi.SelfHost。我使用以下示例作为基础。
Following code works for me to launch host on ipv4 localhost endpoint:
以下代码适用于在ipv4 localhost端点上启动主机:
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]:
如果我想指定ipv6地址,我该怎么办? “http:// [:: 1]:43666”不起作用。抛出的异常是[重新格式化]:
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
通过检查反射器中的代码来判断,HttpAddUrlToUrlGroup函数返回错误代码1232
2 个解决方案
#1
8
I did not find a solution, however following is a workaround, although it will start server on all addresses, including non-local and ipv4:
我没有找到解决方案,但以下是一种解决方法,虽然它将在所有地址启动服务器,包括非本地和ipv4:
WebApp.Start<Startup>("http://+:43666");
Since this question didn't generate any interest I'm closing it
由于这个问题没有产生任何兴趣,我正在关闭它
#2
0
had the same problem and it seemed to be the Account under which the service was running. Need to make sure it's running under NetworkService - both localhost and other variations of URLs should work then :)
有同样的问题,它似乎是服务运行的帐户。需要确保它在NetworkService下运行 - localhost和其他URL的变体应该可以工作:)
#1
8
I did not find a solution, however following is a workaround, although it will start server on all addresses, including non-local and ipv4:
我没有找到解决方案,但以下是一种解决方法,虽然它将在所有地址启动服务器,包括非本地和ipv4:
WebApp.Start<Startup>("http://+:43666");
Since this question didn't generate any interest I'm closing it
由于这个问题没有产生任何兴趣,我正在关闭它
#2
0
had the same problem and it seemed to be the Account under which the service was running. Need to make sure it's running under NetworkService - both localhost and other variations of URLs should work then :)
有同样的问题,它似乎是服务运行的帐户。需要确保它在NetworkService下运行 - localhost和其他URL的变体应该可以工作:)