'How to access ASP.NET Core web server from another device

I created a project using C# and ASP.NET Core empty and it worked on localhost - how can I access it from another device using the IP of the computer running the project?

enter image description here

enter image description here

enter image description here



Solution 1:[1]

You need to configure kestrel to bind requests from 0.0.0.0 instead of localhost to accept requests from everywhere.

You can achieve this with different methods.

1- Run application with urls argument

dotnet app.dll --urls "http://0.0.0.0:5000;https://0.0.0.0:5001"

2- Add kestrel config to appsettings.json (Or any other way that you can inject value to IConfiguration)

{
 ...
  "Kestrel": {
    "Endpoints": {
      "Http": {
        "Url": "http://0.0.0.0:5000"
      },
      "Https": {
        "Url": "https://0.0.0.0:5001"
      }
    }
  }
  ...
}

3- Hard-code your binding in the program.cs file.

and the result should look like this

enter image description here

For complete details, please visit https://docs.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel/endpoints

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 MrMoeinM