Using Kestrel with .NET 7: Why can't I access ASP.NET Core app from another computer on the same network without IIS.

Orion-8602 0 Reputation points
2023-04-07T07:30:16.38+00:00

Greetings everyone!

Using .NET 7, I created a simple ASP NET CORE app.
I am attempting to use only Kestrel without IIS to run this app. in appsettings.json:

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

I have tried every other configuration imaginable but nothing works.
In code, I attempted to configure Kestrel but nothing works.

Firewall turned off and the app works on the same machine but not the other computers on the same network.

Developer technologies ASP.NET ASP.NET Core
Developer technologies .NET Other
{count} votes

2 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2023-04-07T15:08:28.39+00:00

    if the apps works on the local machine, then it is configured correctly. to access from another machine, the firewall needs to be open on both machine. if you opened on the server, then its probably the client firewall.

    note: 5000 and 5001 are not well know ports (0 to1023), nor are they in the dynamic range (49152 to 65535) that is typically open by default.

    0 comments No comments

  2. Anonymous
    2023-04-11T05:08:09.3366667+00:00

    Hi @Orion-8602, Thanks for your patience. I took the test today and now I will share my results. We should use

    builder.WebHost.UseUrls("http://0.0.0.0:5000"); 
    

    Instead of builder.WebHost.UseUrls("http://*:5000"); ,then we can solve this problem. Here is my test code, I use 5031 port, when I double click .exe , file, then we can find the application start with 5031 port. User's image

    User's image

    Summary

    1. This kind of format with * , like [http://*:5000], used for launchSettings.json file.
    2. No need to run netsh http add urlacl command, you can refer the document and delete it

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best regards,

    Jason Pan

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.