Search code examples
.net-corewebapiswashbuckle.aspnetcore

Deploying dotnetcore 5 web api to iis gives 404


I have an Web API project with .NET 5 (created directly from the template of visual studio Asp.NET Core Web API), it works just fine when debugging from Visual studio, tried to deploy it to IIS server, which has the Hosting Bundle of .NET 5 installed, the deployment apparently runs fine, but when I enter the url I have a 404. Have a separate MVC .NET 5 project, which I deploy in the same way and it runs perfectly fine.

Would like to know if someone can point me to the right direction, can't find what I'm missing here.


Solution

  • After searching and messing with Startup.cs file I notice that

        app.UseSwagger();
        app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "api v1"));
    

    Was inside the validation if(env.IsDevelopment()), but the api endpoints were working just fine, just that though that it doesn't work because I was unable to see the Swagger site, probably because you don't want to expose your api to everyone... feels like I miss a little explanation somewhere but all good now.