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.
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.
Faced the same issue. After configuring, when tried to browse 404 error came up.
The reason is, Swagger page will be configured in only for development environment as below(in Startup.cs).
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseSwagger();
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "AppName v1"));
}
The APIs will be available if we type in the correct url. If you still wants to view the Swagger file
Either change the code in startup.cs remove the check for
if (env.IsDevelopment())
Or In your web.config file set environment as Development.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With