我有Controller两个动作,Logon没有任何装饰器和LogOn装饰[HttpPost]器。
代码:
public ActionResult LogOn()
{
return View();
}
[HttpPost]
public ActionResult LogOn(string username, string password,
bool? rememberMe, string returnUrl)
{
AccountService client = new AccountService();
if (client.IsUserAllowedIn(username, password))
FormsAuthentication.SetAuthCookie(username, rememberMe ?? false);
return Redirect(returnUrl);
}
我面临的问题是:当我尝试使用[Authorize]装饰器访问方法时,ASP.NET MVC不会重定向到我LogOn使用[HttpPost]装饰器的操作。
出于测试目的,我创建了一个名为LogOnusing的表单,Post它可以正常工作。所以我想问题在于我使用装饰器的方式。
我的web.config:
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" timeout="2880" />
</authentication>
关于我做错了什么的任何想法?