I'm building Asp.Net Core 2.x web api integrated with Swagger. To access the swagger, I had to append /swagger to the url, eg. https://mywebapi.azurewebsites.net/swagger/
How can I redirect https://mywebapi.azurewebsites.net/ to https://mywebapi.azurewebsites.net/swagger/ ?
Install Microsoft.AspNetCore.Rewrite from Nuget
In Startup.cs
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
before
app.UseMvc();
add
var option = new RewriteOptions(); option.AddRedirect("^$", "swagger"); app.UseRewriter(option);
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