I'm working on a .NET 6 web api and I've configured the Program.cs to use Swagger UI when in development mode. How can I change this so that I still have access to Swagger UI but by default load the default view?
For example, when I run my project, it loads https://localhost:7004/swagger/index.html
instead I want to load https://localhost:7004
but still have access to https://localhost:7004/swagger/index.html
Current Program.cs:
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseStaticFiles();
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.MapControllerRoute(
name: "default",
pattern: "{controller=ControllerName}/{action=Index}/{id?}");
Open your project's priperties (screenshot below -)
Under the 'Debug'section, click on 'Open debug launch profiles UI'. This should open the UI shown below -
Remove the text 'swagger', leave it blank, restart your application. This should navigate to -
Note that you can still enter full path to swagger link to navigate to it -