0

Issue: default URL is not working properly when deploying ASP.NET Core 8 MVC on IIS (Windows Server).

In my ASP.NET Core 8 MVC application, I specified the launchUrl in the launchSettings.json file. It works correctly in local development - when I start the application, it automatically opens the specified launch URL (e.g., http://localhost:20395/Auth/Login).

However, after deploying the application to IIS on a Windows Server, the application opens with http://localhost/MyAppName instead of the expected http://localhost/MyAppName/Auth/Login.

What could be the reason for this behavior, and how can I configure IIS to use the correct launch URL?

My launchSettings.json:

{
  "profiles": {
    "http": {
      "commandName": "Project",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      },
      "launchUrl": "Auth/Login",
      "dotnetRunMessages": true,
      "applicationUrl": "http://localhost:5298"
    },
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "launchUrl": "Auth/Login",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development",
        "ASPNETCORE_HOTRELOAD_MAXRULES": "15000"
      }
    },
    "WSL": {
      "commandName": "WSL2",
      "launchBrowser": true,
      "launchUrl": "http://localhost:5298",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development",
        "ASPNETCORE_URLS": "http://localhost:5298"
      },
      "distributionName": ""
    }
  },
  "$schema": "http://json.schemastore.org/launchsettings.json",
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:20395",
      "sslPort": 0
    }
  }
}

1 Answer 1

1

This is because the lunchsetting.json is not work when deploying to the IIS.

If you want to set the default url inside the asp.net core application, I suggest you could modify the default route for your MVC application like below in program.cs:

app.MapControllerRoute(
    name: "default",
    pattern: "{controller=Auth}/{action=Login}");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.