简体   繁体   中英

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 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!

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) eg --server.urls http://mypc:5000 .

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

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.

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.

  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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM