Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wildcards in asp.net mvc routes

Tags:

asp.net-mvc

i'm using asp.net mvc with vs2008 and IIS7. What i want to accomplish is that all requests that START WITH 'summer' are routed to the same controller. 'till now i've built tons of routes, but they were all for one path (with parameters offcourse) but this one must route: www.mysite.com/summercity www.mysite.com/summermadness www.mysite.com/summer www.mysite.com/summerweather

to the same controller.

the only solution i've come up with is 'summer*', but that didn't work :)

Michel

like image 313
Michel Avatar asked Aug 13 '09 08:08

Michel


People also ask

What does wildcard * * In a route path represent?

A Wildcard route has a path consisting of two asterisks (**). It matches every URL, the router will select this route if it can't match a route earlier in the configuration. A Wildcard Route can navigate to a custom component or can redirect to an existing route.

Can we have multiple routes in MVC?

Multiple Routes You need to provide at least two parameters in MapRoute, route name, and URL pattern. The Defaults parameter is optional. You can register multiple custom routes with different names.

How many routes are there in MVC?

ASP.NET MVC offers two approaches to routing: The route table, which is a collection of routes that can be used to match incoming requests to controller actions.

What is routing in MVC 5 with example?

Routing is a pattern matching system. Routing maps an incoming request (from the browser) to particular resources (controller & action method). This means routing provides the functionality to define a URL pattern that will handle the request. That is how the application matches a URI to an action.


1 Answers

You can use:

/Summer{*Data}
like image 118
CD.. Avatar answered Sep 21 '22 17:09

CD..