none
HttpListener access denied, netsh "+" wildcard not working RRS feed

  • Question

  • I use a ServiceHost object to create a HTTP service: http://{IP}:80/myService

    My application runs from a non-admin account (and this must be kept like this). From several sources I found that the solution was calling the following from an administrator cmd prompt:

    netsh http add urlacl url=http://+:80/myService/ user=Everyone

    This does not work, I still get an exception regarding access 

    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()

    However if I call this line, it works:

    netsh http add urlacl url=http://127.0.0.1:80/myService/ user=Everyone

    Note I explicitely specified the IP. I don't know the IP that the user will be using, so I need the + wildcard to work. I cannot figure out why it is not working and I cannot find a workaround to this.

    Thursday, February 9, 2017 1:01 PM

All replies

  • Hi Sergio.cs,

    What is your windows version?

    >> From several sources I found that the solution was calling the following from an administrator cmd prompt

    Do you mean you run the command in administrator cmd prompt? I made a test with this, but I failed to reproduce this issue. Did you change the login account by administrator or run the Command Prompt by entering administrator user and password?

    I suggest you follow

    #cmd prompt registerdns replies "the requested operation requires elevation"

    https://answers.microsoft.com/en-us/windows/forum/windows_7-files/cmd-prompt-registerdns-replies-the-requested/17432fb0-0d7c-4c55-ba76-d9724395889a

    Note, you need to enter valid administrator account instead of non-admin account.

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Friday, February 10, 2017 8:24 AM