Asp.net mvc asp.net MVC自定义路由

Asp.net mvc asp.net MVC自定义路由,asp.net-mvc,url-routing,asp.net-mvc-routing,Asp.net Mvc,Url Routing,Asp.net Mvc Routing,嗨,我在代码中使用了这两行: using (Ajax.BeginForm("Login", "Users", new { command = "Login"}, new AjaxOptions() { UpdateTargetId = "divLoginPopupContent" }, new { id = "loginPopup" })) { /// some html with submit button // and also have following: &l

嗨,我在代码中使用了这两行:

using (Ajax.BeginForm("Login", "Users", new { command = "Login"}, new AjaxOptions() { UpdateTargetId = "divLoginPopupContent" }, new { id = "loginPopup" }))
{
    /// some html with submit button

    // and also have following:
    <%= Html.ActionLink("Forgot your password", "Login", "Users", new { command = "ForgotPassword" }, null)%>
}
这是控制器的动作:

public ActionResult Login(LoginModel model, string command)
     {
          /// some actions
     }

但我不知道我做错了什么。。。我希望ActionLink和BeginForm都被路由到此控制器操作。

回答我自己的问题:

我还没有定义另一个路由集合变量,即应该声明command,如下所示

routes.MapRoute(
                "Users",
                "Users/{command}",
                new { controller = "Users", action = "Login", 
                command = Parameter.Optional }
            );

陛下你面临什么样的错误?我只是用了你的代码片段,一切看起来都很好。。使用actionlink和submit按钮,我可以通过适当的命令正确地路由到登录操作…因为我的参数中有模型,所以它不会将我带到该操作…并给我这个错误HTTP 404。您正在查找的资源(或其依赖项之一)可能已被删除、名称已更改或暂时不可用。请检查以下URL并确保其拼写正确。
routes.MapRoute(
                "Users",
                "Users/{command}",
                new { controller = "Users", action = "Login", 
                command = Parameter.Optional }
            );