asp.net MVC 自定义路由
您好,我在代码中使用这两行:
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 都被路由到这个控制器动作。
Hi I am using this two lines in my code:
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)%>
}
and this is the map route i have
routes.MapRoute(
"Users",
"Users/{command}",
new { controller = "Users", action = "Login" }
);
and this is the controller action:
public ActionResult Login(LoginModel model, string command)
{
/// some actions
}
but I don'y what I am doing wrong here ... I want ActionLink and BeginForm both to be routed to this controller action.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
回答我自己的问题:
我还没有定义另一个路由集合变量,即应该声明命令,如下所示
answering my own question:
i haven't define another route collection variable i.e. command should be declared, like this