ASP.NET 5 Self-Host
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 uses http: // localhost: 5000 ...
I want to know how can I hide a site from another PC without using localhost. As an IP address or without DNS.
Please help me!
source to share
I had the same problem trying to connect to the host itself and was only available locally. I checked with Angry IP Scanner and saw that the port was not even open when the application was running so explicitly, which would prevent remote access.
I eventually figured out that the command --server.urls
should basically work like bindings in IIS, so when you have --server.urls http://localhost:5000
, you just need to change localhost
for your computer name or IP address (or add both), for example. --server.urls http://mypc:5000
...
It worked for me, so I hope it works for you!
source to share
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, you need to run the process (or VS) as administrator.
source to share
You must allow incoming connections for your application:
First start an admin 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
It just tells http.sys that its ok to talk to that url.
source to share
- Modify your firewall to allow TCP connections on the exposed port (like 5000 in this case).
- Your device will have a machine name. This way you can access the website from another computer using http: //: 5000 /
Note that you can only access the machine if the other computer is also on the same LAN. Just use "ping" to quickly see if both machines are on the same network.
source to share