How do I set Swagger as the default start page in ABP template instead of /Account/Login
?
I'm using ASP.NET MVC 5.x + Angular 1.x.
Current code:
public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); //ASP.NET Web API Route Config 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 } ); }
Everything is still working fine, except Module Zero's "api/Account/Authenticate"
request that has broken, showing:
The resource cannot be found.
Add and configure Swagger middleware The generated document describing the endpoints appears as shown in OpenAPI specification (openapi. json). The Swagger UI can be found at https://localhost:<port>/swagger .
Swagger (OpenAPI) is a language-agnostic specification for describing REST APIs. It allows both computers and humans to understand the capabilities of a REST API without direct access to the source code.
For a RESTFUL API in ASP Net Core >2.2, set the default URL in Project/Properties/ Debug
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 } ); }
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