I would like my MVC website to be able to route the following URLs:
http://www.example.com/{userId}
http://www.example.com/{userId}/enroll
Note: userId
is a string of letters, numbers and/or hyphens.
I realize this is problematic because the URL does not specify a controller name. However, it should be possible in theory. I can use reflection to get a list of all the controllers in my application. If {userId}
does not match any of those controllers, then it should be redirected to a particular controller/action.
My first question is how would you specify a map like this? I can specify a string value, I can even specify a regular expression. But how can I filter based on whether or not it matches a list of strings?
Beyond that, just wondered if anyone else has thought of doing things and if they have any other creative ideas on how I might accomplish it.