我正在尝试在 ASP.NET MVC 4 应用程序中设置登录表单。目前,我已经配置了我的视图,如下所示:
路由配置.cs
routes.MapRoute(
"DesktopLogin",
"{controller}/account/login",
new { controller = "My", action = "Login" }
);
我的控制器.cs
public ActionResult Login()
{
return View("~/Views/Account/Login.cshtml");
}
[AllowAnonymous]
[ValidateAntiForgeryToken]
public ActionResult Login(LoginModel model)
{
return View("~/Views/Account/Login.cshtml");
}
当我尝试在浏览器中访问 /account/login 时,我收到一条错误消息:
The current request for action 'Login' on controller type 'MyController' is ambiguous between the following action methods:
System.Web.Mvc.ActionResult Login() on type MyApp.Web.Controllers.MyController
System.Web.Mvc.ActionResult Login(MyApp.Web.Models.LoginModel) on type MyApp.Web.Controllers.MyController
如何在 ASP.NET MVC 4 中设置基本表单?我查看了 ASP.NET MVC 4 中的示例 Internet 应用程序模板。但是,我似乎无法弄清楚路由是如何连接的。非常感谢你的帮助。