デコレータなしとデコレータ付きController
の2つのアクションがあります。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]
LogOn
テストの目的で、 usingというフォームを作成しましたが、Post
機能しました。したがって、問題はデコレータの使用方法にあると思います。
私のweb.config
:
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" timeout="2880" />
</authentication>
私が間違っていることについて何か考えはありますか?