我使用以下代码创建了一个简单的 MVC4 应用程序:
控制器:
[AllowAnonymous]
[HttpGet]
[ValidateAntiForgeryToken]
public ActionResult Login(LoginModel model)
{
return View();
}
看法:
<div>
@using (Html.BeginForm("Login","Administrator",FormMethod.Get))
{
@Html.ValidationSummary(true)
@Html.AntiForgeryToken()
@Html.LabelFor(x=>x.username)
@Html.TextBoxFor(x=>x.username)
@Html.LabelFor(x=>x.password)
@Html.TextBoxFor(x=>x.password)
<input type="submit" value="Submit" />
}
</div>
运行应用程序并转到此地址后:http://xxx/Administrator/Login
我收到了这个错误:
The required anti-forgery cookie "__RequestVerificationToken" is not present.
那有什么问题?