MVC 3 Custom Route Handler - Skip to Next Custom Route Rule?

You should be able to achieve this pretty simply.

Up vote 2 down vote favorite share g+ share fb share tw.

Was looking at asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net mvc complex routing for tree path as an example of how to define a custom route handler for my MVC app. Essentially, I want to give the end user ultimate flexibility in defining the URL for any given page, so I provide them with a field in the interface to specify their own custom URL. My custom route handler is basically a wild-card handler.

It will do a lookup and if it finds a match, map it accordingly. However, if no match is found, I want it to fall back and find the next rule that matches in the global.asax. Is that possible?

Or do I essentially need to code the mappings that used to exist in my global. Asax into my custom route handler? C# asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net-mvc asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net-mvc-3 asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net" rel="nofollow">asp.net-mvc-routing link|improve this question asked Mar 14 '11 at 20:09Sam1,024616 92% accept rate.

You should be able to achieve this pretty simply. Just have a catch all route that sits below your more specific routes, handle the catch all in your controller. I guess you will just look for a page key then return the page to the user.

Routing already works this way When a certain route definition doesn't match request's URL, routing skips to next route definition and so on and so forth. Until: it finds a route that mathes request URL fails with the last route definition throwing a 404 Provide an example of how your routing should work and we'll easier give you information whether custom route handler or route is the way to go in your case.

Robert, essentially there are no rules for how the end user creates their URL. They may be migrating from another system and want to keep their old URLs, may want a short sweet url for sharing/promotional, etc. So essentially, I need to have a wildcard mapping that catches anything other than the home page. But now that you mention it, maybe I should just put in the wildcard route after my standard routes.

This probably satisfies 99% of the cases. – Sam Mar 14 '11 at 22:29 1 @Sam: I don't know (you should) but if you need greedy segment anywhere in route URL definition I've written a class that supports just that. Check my blog: erraticdev.blogspot.com/2011/01/… Just in case you need something like that.

– Robert Koritnik Mar 15 '11 at 8:16 Nice blog, thanks for the link. – Sam Mar 16 '11 at 14:19 @Sam: you're welcome. Always glad to hear that my mumblings are useful to others.

– Robert Koritnik Mar 16 '11 at 19:12.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions