您好我在我的代码中使用了这两行:
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)%>
}
这是我的地图路线
routes.MapRoute(
"Users",
"Users/{command}",
new { controller = "Users", action = "Login" }
);
这是控制器动作:
public ActionResult Login(LoginModel model, string command)
{
/// some actions
}
但我不知道我在这里做错了什么...我希望ActionLink和BeginForm都被路由到这个控制器动作。
答案 0 :(得分:2)
回答我自己的问题:
我没有定义另一个路径收集变量,即应声明命令,如此
routes.MapRoute(
"Users",
"Users/{command}",
new { controller = "Users", action = "Login",
command = Parameter.Optional }
);