Search code examples
c#asp.net.netlan

Connect device on LAN to ASP.NET Core Web API


I'm running VS2019 community, and I've created the default ASP.NET Core Web API project (ASP.NET Core 5.0), the one with the simple weather forecast example. And I am now trying to connect another computer to the URL. I run the example by using the [application name] in the run dropdown, and not IIS Express.

Both computers are connected via wifi to the same Router. I do an ipconfig on the server machine to get it's IP (192.168.1.108) And I have also enabled inbound connections from the ports 5000-5001 in the windows firewall setup

On the "client" machine I try to access the server with :

http://192.168.1.108:5000/swagger/index.html

or

https://192.168.1.108:5001/swagger/index.html

but neither seem to work? The page ends up timing out.

So on the machine running the server, I also completely disabled the windows firewalls (temporally, just to get things working).

But still get the same result?

Have I missed a step?


Solution

  • Maybe this will help you. Try to add IP of your host into Program.cs
    var host = new WebHostBuilder().UseUrls("http://192.168.1.108:5000")