I create an out of the box asp.net core 2.1 web app with react. When I run it, it hosts on localhost:(some port). I want to access that on my mobile device.
I tried accessing it from localhost by adding the port to the Inbound Rules on Windows Defender Firewall.It didn't work so I wanted to change the ip address to 0.0.0.0:(some port) or to host it on my local IPv4 address by changing the lauchSettings.json and Program.cs by .UseUrls method. It didn't work, gave me an error that the app cannot run. I tried using my external IP address which I got from asking "My ip address" in Google but that didn't help as well.
I use this, maybe it can help
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseUrls("https://*:5566")
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>();
Note that for the latest .Net, you set the URLs in the launchSettings.json file as shown below:
Make sure to enable the port 5566 in firewall. From the phone access https://your_comp_ip_address:5566/ it should work. Change your_comp_ip_address to your computer ip address, you can check it from the CMD. Just run 'ipconfig' in the CMD
From Visual Studio, run the App itself, not IIS Express, select AppNamefrom the drop down, then press F5. Kindly Check all of these photos below:
In most cases, all you will have to do is replace "localhost"
with a wildcard *
(or with your local LAN IPv4 Address) in Properties/launchSettings.json:
{
// ...
"profiles": {
// ...
"Moshoboga": {
// ...
// replace: "applicationUrl": "https://localhost:5001;http://localhost:5000"
"applicationUrl": "https://*:5001;http://*:5000"
}
}
}
Then navigate to your local ip in any browser on your LAN. Find this with ipconfig
on Windows, or ifconfig
on Unix/Linux
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With