免責聲明:到this question類似,這個人是具體到最投票評論從answer的Windows的netsh「+」通配符不工作的ServiceHost
我使用的ServiceHost對象來創建一個HTTP服務:http: // {IP}:80/myService
我的應用程序從非管理員帳戶運行(並且必須保持這樣)。從幾個來源,我發現該解決方案在呼喚從管理員以下命令提示符:
netsh http add urlacl url=http://+:80/myService/ user=Everyone
這是不行的,我仍然得到關於訪問的例外:
System.ServiceModel.AddressAccessDeniedException: HTTP could not register URL http://127.0.0.1:80/myService/. Your process does not have access rights to this namespace (see http://go.microsoft.com/fwlink/?LinkId=70353 for details). ---> System.Net.HttpListenerException: Access is denied
at System.Net.HttpListener.AddAllPrefixes()
at System.Net.HttpListener.Start()
at System.ServiceModel.Channels.SharedHttpTransportManager.OnOpen()
--- End of inner exception stack trace ---
at System.ServiceModel.Channels.SharedHttpTransportManager.OnOpen()
at System.ServiceModel.Channels.TransportManager.Open(TransportChannelListener channelListener)
at System.ServiceModel.Channels.TransportManagerContainer.Open(SelectTransportManagersCallback selectTransportManagerCallback)
at System.ServiceModel.Channels.TransportChannelListener.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.HttpChannelListener`1.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open()
但是如果我叫這條線,它的工作原理:
netsh http add urlacl url=http://127.0.0.1:80/myService/ user=Everyone
注意我明確地指定的T他IP。我不知道用戶將使用的IP,所以我需要+通配符才能工作。我不明白爲什麼它不工作,我找不到解決方法。
- 作爲管理員的Runnin不是解決方案。
- 從微軟UrlPrefix通配符找到信息,但目前尚不清楚
在命令末尾添加「listen = yes」是否會改變任何內容? –
listen = yes是默認值,我也嘗試了delegate = yes但它沒有任何作用 –