tags:

views:

126

answers:

2

My mind is somehow blank. How do I do this:

I have a RegistrationController and want the URL /register to hit the action Register on that controller. What do I have to add as a map route in global.asax?

A: 
routes.MapRoute(
                "MyCustomRoute",                                              // Route name
                "Registration/Register",                           // URL with parameters
                new { controller = "Registration", action = "Register" }  // Parameter defaults
            );
Marwan Aouida
That would work only with the URL http://www.yoursite.com/Registration/Register. I believe Alex wants something like http://www.yoursite.com/Register.
Gerardo Contijoch
+1  A: 

Actually, what you want is this:

routes.MapRoute(
            "RegisterRoute",
            "Register",
            new { controller = "Registration", action = "Register" }
        );

Now you can go to your page with an url like:

http://www.yoursite.com/register

Gerardo Contijoch
You're right. It needs to only have "Register" in the URL definition. Thank you!
Alex