我有一个表格帖子,一直给我一个反伪造令牌错误.
这是我的表格:
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
@Html.EditorFor(m => m.Email)
@Html.EditorFor(m => m.Birthday)
<p>
<input type="submit" id="Go" value="Go" />
</p>
}
Run Code Online (Sandbox Code Playgroud)
这是我的行动方法:
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Join(JoinViewModel model)
{
//a bunch of stuff here but it doesn't matter because it's not making it here
}
Run Code Online (Sandbox Code Playgroud)
这是web.config中的machineKey:
<system.web>
<machineKey validationKey="mykey" decryptionKey="myotherkey" validation="SHA1" decryption="AES" />
</system.web>
Run Code Online (Sandbox Code Playgroud)
这是我得到的错误:
A required anti-forgery token was not supplied or was invalid.
Run Code Online (Sandbox Code Playgroud)
我已经读过,更改HttpContext上的用户会使令牌无效,但这不会发生在这里.我的Join操作上的HttpGet只返回视图:
[HttpGet]
public ActionResult Join()
{
return this.View();
}
Run Code Online (Sandbox Code Playgroud)
所以我不确定发生了什么.我一直在搜索,似乎所有东西都表明它是机器键更改(应用程序周期)或用户/会话更改.
还有什么可以继续?我该如何解决这个问题?