Asp.net

OWIN 理解 ipv6 自託管的 URL 是什麼?

  • July 21, 2016

我的應用程序使用ASP.NET Web API的自託管功能。我使用的 NuGet 包名稱是 Microsoft.AspNet.WebApi.SelfHost。我使用以下範例作為基礎。

以下程式碼適用於我在 ipv4 localhost 端點上啟動主機:

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

如果我想指定 ipv6 地址,我應該輸入什麼?“http://

$$ ::1 $$:43666" 不起作用。拋出的異常是$$ 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)

從我檢查反射器中的程式碼來看,該HttpAddUrlToUrlGroup函式返回錯誤程式碼 1232

我沒有找到解決方案,但是以下是一種解決方法,儘管它會在所有地址上啟動伺服器,包括非本地和 ipv4:

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

由於這個問題沒有引起任何興趣,我將關閉它

有同樣的問題,它似乎是執行服務的帳戶。需要確保它在 NetworkService 下執行 - localhost 和其他 URL 變體都應該可以工作:)

引用自:https://stackoverflow.com/questions/18707411