Skip to content
This repository has been archived by the owner on Dec 19, 2018. It is now read-only.

Hosting with Microsoft.AspNet.Server.WebListener does not work in RC1 #503

Closed
BillDines opened this issue Nov 24, 2015 · 9 comments
Closed

Comments

@BillDines
Copy link

Functional impact

If you use Microsoft.AspNet.Server.WebListener as your server when hosting an Asp.Net 5 application it fails during startup, terminating the process.

Minimal repro steps

  1. Run Visual Studio 2015 Update 1 NOT as an administrator*

  2. Create a new Asp.Net 5 project using the project template in Visual Studio 2015 Update 1

  3. Add a dependency to Microsoft.AspNet.Server.WebListener in project.json.

    "dependencies": {
    ....,
    "Microsoft.AspNet.Server.WebListener": "1.0.0-rc1-final",
    ....
    },

  4. Add a new command for WebListener
    "commands": {
    ...,
    "webListener": "Microsoft.AspNet.Server.WebListener",
    ...
    },

  5. Start the webListener Command.

Expected result

A console app should start, hosting the web application using WebListener and listening on port 5000 (this worked OK in beta-8)

Actual result

The console app crashes with the following exception:

Microsoft.Net.Http.Server.WebListener: Information: Start
Microsoft.Net.Http.Server.WebListener: Information: Listening on prefix: http://localhost:5000/
Microsoft.Net.Http.Server.WebListener: Error: Start
Microsoft.Net.Http.Server.WebListenerException (0x80004005): Access is denied
at Microsoft.Net.Http.Server.UrlPrefixCollection.RegisterPrefix(String uriPrefix, Int32 contextId)
at Microsoft.Net.Http.Server.UrlPrefixCollection.RegisterAllPrefixes()
at Microsoft.Net.Http.Server.WebListener.Start()

Further Information

Firewall is configured correctly to allow listening on port 5000. This can be tested by using Microsoft.AspNet.Server.Kestrel instead, which works fine.
The host machine is running Windows 7 Professional Service Pack 1

*WebListener will start if run as an administrator but you get "HTTP Error 503. The service is unavailable" if you try and access the application.

@davidfowl
Copy link
Member

Are you trying to run this behind the platform handler? That's not supported. Use kestrel.

@BillDines
Copy link
Author

@davidfowl - do you mean IISPlatformHandler? As in app.UseIISPlatformHandler() in Startup.Configure()? The behaviour is the same with or without it. I want to self host the application on Windows (i.e. no IIS) and I need Windows Authentication so I think WebListener is my only option??

@Tratcher
Copy link
Member

WebListener self-host should be fine, just don't use it with IIIS/Express (the default F5 in VS).

@Tratcher
Copy link
Member

That port may have been reserved for another app. See netsh.exe. You can try another port by adding "webListener": "Microsoft.AspNet.Server.WebListener --server.urls=http://localhost:5001/"

@BillDines
Copy link
Author

@Tratcher Thanks for the response.

At some point I had used netsh to allow listnening on port 5000 for the user I am using to run the asp.net application:

netsh http add urlacl url=http://+:5000/ user=

Until now I thought that was required to allow listening for http on a port. In fact it prevents you listening on a port with WebListener! Kestrel will work though.

@BillDines
Copy link
Author

As far as I am concerned the issue can be closed, but I am not sure I am able to do it??

@Tratcher
Copy link
Member

The issue is that the url you pass into netsh must match the one you give to weblistener. You do not need to preregister with netsh for localhost or running as admin.

Kestrel is unaffected by netsh because it uses raw sockets, not http.sys.

@BillDines
Copy link
Author

I thought the url did match, but maybe I was missing a / or "+" doesn't work in this instance. Anyway, I am working with localhost, which is all I need right now. Now I know what is required I'm sure I can work out what I need to do when I want to access my application from remote machines.

Thanks for your help.

@Tratcher
Copy link
Member

  • does not match localhost from a registration perspective, registrations need to be exact string matches. If you used + in both places then it would match localhost sent from the client.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants