Has anyone worked with an Asp.net Core Web API project implementing API versioning in .Net 8.0 and successfully deployed it in IIS?

Kesava Subhash Gullapudi 30 Reputation points
2024-02-03T06:59:39.54+00:00

I've implemented API versioning using Asp.Net Core web API in .Net 8.0 Framework, and it works fine in the debugger with Swagger. But when I deploy my application using IIS, I get an error page saying "Page can't be found". How can I resolve this issue?

Windows development Internet Information Services
Developer technologies ASP.NET ASP.NET Core
{count} votes

1 answer

Sort by: Most helpful
  1. Kesava Subhash Gullapudi 30 Reputation points
    2024-02-12T06:56:41.1966667+00:00

    builder.Services.AddApiVersioning(config => { config.DefaultApiVersion = new ApiVersion(1, 0); config.AssumeDefaultVersionWhenUnspecified = true; config.ReportApiVersions = true; }); builder.Services.ConfigureOptions<ConfigureSwaggerOptions>(); if (app.Environment.IsDevelopment() || app.Environment.IsProduction()) { app.UseSwagger(); app.UseSwaggerUI(options => { var apiVersionDescriptionProvider = app.Services.GetRequiredService<IApiVersionDescriptionProvider>(); foreach (var description in apiVersionDescriptionProvider.ApiVersionDescriptions) { options.SwaggerEndpoint($"/swagger/{description.GroupName}/swagger.json", description.GroupName.ToUpperInvariant()); } }); }

    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.