Farid
Farid

Reputation: 1020

Cannot browse to site hosted in IIS Express even though successfully registered

I'm trying to run an ASP.NET Core MVC application (100% template) in IIS Express. It seems the site is already hosted in IIS Express, but when I open the site in browser, I got the generic error "This site can't be reached". Any idea?

From Visual Studio:

Starting IIS Express ...
Successfully registered URL "http://localhost:55516/" for site "WebApplication1" application "/"
Successfully registered URL "https://localhost:44331/" for site "WebApplication1" application "/"
Registration completed for site "WebApplication1"
IIS Express is running.
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Development

Looking at DevTool, this is the response I got:

enter image description here

My launchSettings.json:

{
  "iisSettings": {
    "windowsAuthentication": true,
    "anonymousAuthentication": false,
    "iisExpress": {
      "applicationUrl": "http://localhost:55516",
      "sslPort": 44331
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "WebApplication1": {
      "commandName": "Project",
      "launchBrowser": true,
      "applicationUrl": "https://localhost:5001;http://localhost:5000",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}

Edit: Interestingly, would not run if I F5 from VS. If I run "dotnet run" from CLI, it runs perfectly fine... Why???

Upvotes: 1

Views: 110

Answers (1)

Picsonald
Picsonald

Reputation: 311

I had the same issue today with an ASP .NET MVC 5 application (Framework .NET 4.8.1). After several attempts to restart Visual Stutio 2022, cleaning up the solution, restarting the computer... It turned out that everything was linked to the ‘Enable Edit and Continue’ checkbox under ‘Web’ configuration tab. Each action on this checkbox must be followed by a clean restart of Visual Studio 2022.

Enable Edit and Continue then Restart VS 2022

Upvotes: 0

Related Questions