MayankGaur
MayankGaur

Reputation: 993

How to set default swagger welcome page in Web Api

I have created a Web Api, and I want to set default landing url as Swagger url i.e:- http://localhost:65347/swagger/ui/index

Upvotes: 4

Views: 5443

Answers (2)

Fütemire
Fütemire

Reputation: 1893

Maybe not the most accurate answer, but I simply set the Startup URL in my project to the Swagger page. You'll have to make sure the path is correct when you deploy, but works great for me when debugging on my workstation.....

enter image description here

Upvotes: 3

MayankGaur
MayankGaur

Reputation: 993

I have resolved this by adding below code in RouteConfig.cs

routes.MapHttpRoute( name: "swagger", routeTemplate: "", defaults: null, constraints: null, handler: new RedirectHandler((url => url.RequestUri.ToString()), "swagger"));

Upvotes: 3

Related Questions