Q:

.NET MVC file does not exist error for URL with extra /text

I have set up a similar friendly URL system to stackoverflow's questions. 
The old URL syntax was: localhost:12345:/cars/details/1234
I've already set up the returning 301 and the URL generation but getting a file does not exist error when the url is redirected to:
localhost:12345/cars/details/1234/blue-subaru (because of the last "blue-subaru")
Of course I actually want: localhost:12345/cars/1234/blue-subaru :)
How can I achieve this? Thankyou

A:

This is a routing problem so you should little bit changes in your routing like this 
routes.MapRoute(
               "Default", // Route nameRegister
               "{controller}/{action}/{id}/{name}", // URL with parameters
               new { controller = "test", action = "Index", id = UrlParameter.Optional,name = UrlParameter.Optional } // Parameter defaults
           );

i think this will help you.

A:

You could configure your route to accept the car's name in RouteTable on the global.asax.
routes.MapRoute( 
    "Cars", 
    "Car/{id}/{carName}", 
    new { controller = "Car", action = "Details", id =  UrlParameter.Optional, carName =  UrlParameter.Optional } 
);

And in your CarController you could have your Detail action method and get both parameters (id and carName):
public ActionResult Details(int? id, string carName) 
{ 
   var model = /* create you model */

   return View(model);
}

Your action link should look like this:
@Html.ActionLink("Text", "Details", "Car", new { id = 1, carName="Honda-Civic-2013" })

