How to make that all requests lead to one controller and action (with the exception of static and api, which I will indicate)? Since my factual routing is done by JavaScript on the client, I want to display the same View on any query
2 answers
routes.MapRoute( name: "Default", url: "{*catchall}", defaults: new { controller = "Home", action = "Index" } ); Try this: "{*catchall}" (exactly with an asterisk) will allow you to intercept the request with any number of segments, in defaults write the values that you need. Since the route is quite common - it is better to put it the latest
|
routes.MapRoute( name: "Default", url: "Home/Index/{id}", defaults: new { id = UrlParameter.Optional } ); and for api
routes.MapHttpRoute( name: "API Default", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional }); |