我想在ASP.NET MVC 4应用程序中设置登录表单。目前,我已经配置了我的看法如下所示:在ASP.NET MVC中路由GET和POST路由4
RouteConfig.cs
routes.MapRoute(
"DesktopLogin",
"{controller}/account/login",
new { controller = "My", action = "Login" }
);
MyController.cs
public ActionResult Login()
{
return View("~/Views/Account/Login.cshtml");
}
[AllowAnonymous]
[ValidateAntiForgeryToken]
public ActionResult Login(LoginModel model)
{
return View("~/Views/Account/Login.cshtml");
}
当我试图访问在/帐号/登录浏览器,我收到一个错误,说:
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应用程序模板。但是,我似乎无法弄清楚路由是如何连接的。非常感谢你的帮助。
你想用自定义路线实现什么?乳清没有保留默认路线({controller}/{action}/{id})?默认路线应该可以正常工作。 –
@KevinJunghans - 如果您没有注意到,他的控制器名称与他的网址不同 –
什么是[[ViewSettings(Minify = true)]?我无法找到对此属性的任何参考。这是你创造的东西吗? –