views:

223

answers:

2

I'd like to move an asp.net mvc response to

http://site.com/emails/list/[email protected]

Using RedirectToAction("list", "emails", new { id = "[email protected]"}); takes you to http://site.com/emails/[email protected].

What am I doing wrong?

Thanks,

Rob

A: 

Ah - because the default route requires 'id', your parameters in the view (html) and the controller must be called id.

Rob Ellis
A: 

Seems like misconfigured routing. Your RegisterRoutes method in Global.asax.cs should look like this:

    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            "Default",                                              // Route name
            "{controller}/{action}/{id}",                           // URL with parameters
            new { controller = "Account", action = "Login", id = "" }  // Parameter defaults
        );

    }

In line "{controller}/{action}/{id}" presence of {id} means that is going to be substituted by it's value.

Any other parameter that is not present in routing string would be decoded as ?some_param=value

Andrey Tkach