ASP.NET 5 Kestrel connects to the local network

I would like to connect to my Kestrel server with an ASP.NET 5 application hosted on it from another PC on the same network. Is it possible? I can ping my computer from cmd, but I get "Connection timed out" when I try to connect from a web browser (I type this: "http: // {my_kestrel_ip}: 5000 /").

+3
c # asp.net-mvc
Nov 28 '15 at 20:11
source share
3 answers

In the project folder, you should have a file called hosting.ini . In this default file, you should have something like this:

 server=Kestrel server.urls=http://localhost:5000 

You need to force the HTTP server to listen on your public IP address as well as localhost. To do this, you can add an additional address, separating them with a colon:

 server.urls=http://localhost:5000;http://{my_kestrel_ip}:5000 
+1
Nov 28 '15 at 20:27
source share

.Ini hosting did not work for us. I have to add this to the project.json file. I believe the host.ini file is deprecated after Beta8.

 --server.urls http://0.0.0.0:5000 

or I prefer the following, which, in my opinion, is less confusing.

 --server.urls http://*:5000 

So you end up with something like this in your .json project.

 "commands": { "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.Kestrel --server.urls http://0.0.0.0:5000", "ef": "EntityFramework.Commands" }, 
+9
Dec 04 '15 at 16:28
source share

Just did a quick test that seems to work. Create a host.json file next to the project.json file.

hosting.json:

 { "server.urls": "http://localhost:5000;http://192.168.1.4:5000" } 

project.json:

 "commands": { "web": "Microsoft.AspNet.Server.Kestrel --config hosting.json" }, 

At the command prompt, just run dnx web , the output is:

 Hosting environment: Production Now listening on: http://localhost:5000 Now listening on: http://192.168.1.4:5000 Application started. Press Ctrl+C to shut down. 

You will receive a firwall invitation, accept it and tadaaa !! You can access the site from the local network and localhost.

+1
Mar 19 '16 at 11:35
source share



All Articles