Wednesday, March 12, 2008

ASP.NET MVC Wildcard Routes

I have been having a great time playing with the new MVC Preview 2 bits released on www.asp.net.

I am working on a project however where I needed a url like:

/home/view/2008/spring/easter/morning

and I wanted to put in a route like:

{controller}/{action}/{id}

and I wanted id to get

“2008/spring/easter/morning”

This could be N levels deep so

{controller}/{action}/{id1}/{id2}/{id3}

is not a great solution.

After spelunking around on the www.asp.net forums I found I could do a route like:

{controller}/{action}/{*id}

This directs everything after the action to the id.  Works great!

WideOpen Web

 

Wednesday, March 12, 2008 2:27:34 PM (Pacific Standard Time, UTC-08:00)   #      Comments [1]  
 

Tuesday, April 29, 2008 12:02:45 PM (Pacific Standard Time, UTC-08:00)
I was looking for a solution on this too but you didn't like the forum or really explain how you solved this. What do you do in the controller to get the seperate “2008/spring/easter/morning” items?
Comments are closed.

Administration
Sign In