简体   繁体   中英

How to fix ASP.Net Core 404 error on IIS?

I have been working of a .net core project for weeks, using git, and two weeks ago I added a testing project to the solution (xunit) and for some reasons (I have no idea if the testing project is related in any way to my problem) when I run the api with ISS I get a not found (not a .net error, google's one, see the screenshot below), on chrome (automatically opened with url by ISS & VS) and on postman ... The project always worked, but it does not anymore. I have pulled older branches that I am 100% sure they were working before.

I know it's not a lot of information but I literally have no idea what to start with, so please ask me for any additionnal information.

I also noticed this in the output when running the solution :

  1. Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware:Warning: Failed to determine the https port for redirect.
  2. Microsoft.AspNetCore.Hosting.Internal.WebHost:Information: Request finished in 30.0135ms 200
  3. Microsoft.AspNetCore.Hosting.Internal.WebHost:Information: Request finished in 210.0354ms 404

I have tried :

  • Deleting the solution on local, git pull it again
  • Checking out a local older branch that I'm 100% sure was working before
  • Closing VS / opening again
  • dotnet dev-certs https --trust

在此处输入图片说明

error on screenshots means No webpage was found for the web address: http://localhost:59490 I'm pretty sure my project was working with https before but now the url iis gives me is using http ...

Here is my launchSettings.json

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:59490/",
      "sslPort": 0
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "MyProject": {
      "commandName": "Project",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      },
      "applicationUrl": "http://localhost:59492/"
    }
  }
}

It appears that the launchSettings.json file has bugged out and is no longer correct. Create a new project with the exact same settings as your other project and copy that launchSettings.json over to your project. You will need to change the application name to your project's name.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM