Net 6 API - 404 Not found

ANB 181 Reputation points
2022-01-11T16:45:52.543+00:00

I have developed my API with .NET 6 and locally, I can see all controllers working and using them through swagger.
However when I publish to IIS, I am getting 404 not found.

I also have install Net 6.0.1. Windows Server Hosting, Net Runtime 6.0.1 x64, Net Runtime 6.0.1 x86, ASP.NET Core 6.0.1 Shared Framework.

What could be the problem ?

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,618 questions
{count} votes

10 answers

Sort by: Most helpful
  1. Cem Ergen 1 Reputation point
    2022-03-24T01:04:12.103+00:00

    could be your swagger is disabled on production release.

    0 comments No comments

  2. Antonio Santos 1 Reputation point
    2022-04-08T15:20:19.537+00:00

    In program.cs remove this line

    if (app.Environment.IsDevelopment())

    0 comments No comments

  3. Gabriel Andrade de Sant Anna 1 Reputation point
    2022-07-12T07:39:57.467+00:00

    Has anyone solved this problem?

    I'm going through the same situation

    0 comments No comments

  4. Bruce (SqlWork.com) 66,706 Reputation points
    2022-07-12T16:54:34.13+00:00

    which problem?

    swagger not enabled in prod -> remove if wrapper
    core module not installed -> install
    deployed as sub site -> use correct url: https://server/site/swagger

    if you want swagger UI to be the default page:

    app.UseSwagger();  
    app.UseSwaggerUI(o =>  
    {  
        o.SwaggerEndpoint("/swagger/v1/swagger.json", "v1");  
        o.RoutePrefix = string.Empty;  
    });  
    
    0 comments No comments

  5. elerasoft 1 Reputation point
    2022-09-27T22:18:49.097+00:00

    I am using Asp.net Core 6 and Angular. I lost 2 days solving this issue. I don't know why but when I use files in publish folder I faced this error. Using the published files in bin/release/net6.0 solved my problem.

    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.