如何将MVC路由添加到特定控制器?

Ale*_*lex 7 asp.net-mvc

我的想法有点空白.我该怎么做呢:

我有一个RegistrationController并希望URL 在该控制器上/register执行操作Register.我需要在global.asax中添加什么作为地图路线?

Ger*_*och 11

实际上,你想要的是这样的:

routes.MapRoute(
            "RegisterRoute",
            "Register",
            new { controller = "Registration", action = "Register" }
        );
Run Code Online (Sandbox Code Playgroud)

现在,您可以使用以下网址转到您的网页:

http://www.yoursite.com/register