ASP.NET 5 Self-Host

1.3k views Asked by At

I Have a project in ASP.NET 5 using self-host.

PROJECT.JSON

"commands": {
"web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5000",
"gen": "Microsoft.Framework.CodeGeneration",
"ef":  "EntityFramework.Commands"
},

It using the http://localhost:5000...

I want to know how can i acess the website from another PC, not using localhost. Like a IP with or without DNS.

Please, help me!

4

There are 4 answers

6
whihathac On
  1. Make change in your firewall to allow it TCP connections on the port you expose (eg. 5000 in this case).
  2. Your machine will have a machine name. So you can access the website from another machine using http://:5000/

Note that, you can access the machine only if the other machine is also in the same LAN network. Just use "ping " to quickly see if both the machines are in the same network.

0
tagustini On

I was having the same issue trying to self host and only being able to access locally. I checked with Angry IP Scanner and saw that the port wasn't even open when the app was running so obviously that would prevent remote access.

Eventually I realised the --server.urls command must basically work like bindings in IIS, so where you have --server.urls http://localhost:5000, you just need to change localhost for your computer name or ip address (or add both) e.g. --server.urls http://mypc:5000.

This worked for me so I hope it does for you!

0
Kirill Bestemyanov On

You should allow incoming connections for your application:

First, start an administrative command prompt. Second, run these commands, replacing yourip:yourport with whatever IP and port you are using:

netsh http add urlacl url=http://yourip:yourport/ user=everyone

This just tells http.sys that it’s ok to talk to this url.

0
Martin On

The answer to this question can be found here https://github.com/aspnet/Home/issues/799

Change server.urls=http://localhost:5000 to server.urls=http://*:5000, but if you do that you'll need to run the process (or VS) as admin.