How to set Swagger as default start page?
Add this routing in RouteConfig.cs as commented out here:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
//ASP.NET Web API Route Config
routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
// Set Swagger as default start page
/*
routes.MapHttpRoute(
name: "swagger_root",
routeTemplate: "",
defaults: null,
constraints: null,
handler: new RedirectHandler((message => message.RequestUri.ToString()), "swagger"));
*/
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
For a RESTFUL API in ASP Net Core >2.2, set the default URL in Project/Properties/ Debug
I know the main question was for ASP.Net MVC, but for ASP.Net Core a good solution from this answer on a similar question (using SwaggerUI): https://stackoverflow.com/a/50127631/1179562
app.UseSwaggerUI(c =>
{
c.RoutePrefix = "";
...
};