Search code examples
asp.net-web-apiwebswaggerasp.net-mvc-routingasp.net-web-api-routing

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


Solution

  • 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"));