views:

28

answers:

1

I have this sole route in my app:

routes.MapRoute(
    "Default",                            
    "{controller}/{action}/{id}",         
    new { controller = "Home", action = "Index", id = ""} 
);

This works great for URLs like:

/Blah/Index
/Blah/Create
/Blah/Details/5

I want to add text to that last one like SO does:

/Blah/Details/5/Page-Title-Here-Or-Whatever

So my question is:

What should my routes look like to accomplish this? (or if it doesn't have anything to do with routes...what do I do?)

+2  A: 

MSDN Link: http://msdn.microsoft.com/en-us/library/cc668201.aspx

routes.MapRoute( 
    "Default",                             
    "{controller}/{action}/{id}/{*allTheRest}",          
    new { controller = "Home", action = "Index", id = "", allTheRest=""}  
); 

Function signature should be similar to

    public ActionResult MyAction(int? id, string rest)
    {
        this.TempData["ID"] = id ?? -1000;
        this.TempData["REST"] = rest ?? "Not Provided";
        return View();
    }
No Refunds No Returns
This isn't quite working for me...do I need to restart IIS or clear a cache somewhere?
Michael Haren
Which version of MVC are you using? This is the MVC 2 release that will be included with VS2K10 in a few weeks.
No Refunds No Returns
I created a project from scratch and this does indeed work, thanks! I just need to figure out why it's not working in my existing, IIS-hosted project...
Michael Haren
post your routes in a new question and someone will help you debug. Post the URLs you're passing that you expect to match.
No Refunds No Returns