简体   繁体   中英

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?

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")

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