是否有可能因为另一个表单中的表单而导致Antiforgery MachineKey错误?
防伪令牌无法解密。 如果此应用程序由Web场或群集托管,请确保所有计算机都运行相同版本的ASP.NET网页,并且配置指定显式加密和验证密钥。 AutoGenerate不能在群集中使用。
当我单独放置表单时,两者都有效,但是当我在内部得到上述错误时,我是网络开发中的新手,所以它可能是一个愚蠢的问题(表单内的表单)。
@using (Html.BeginForm()) { @Html.AntiForgeryToken() @Html.ValidationSummary(true) // ... @using (Html.BeginForm("miniCreate", "Client")) { @Html.AntiForgeryToken() @Html.ValidationSummary(true) //... } }Is it possible to get the Antiforgery MachineKey error due to a form inside another form ?
The anti-forgery token could not be decrypted. If this application is hosted by a Web Farm or cluster, ensure that all machines are running the same version of ASP.NET Web Pages and that the configuration specifies explicit encryption and validation keys. AutoGenerate cannot be used in a cluster.
When I put the Forms separately, both work, however when inside i get the mentioned error on both, i am a newbie in the web-development, so it might be a stupid question (form inside a form).
@using (Html.BeginForm()) { @Html.AntiForgeryToken() @Html.ValidationSummary(true) // ... @using (Html.BeginForm("miniCreate", "Client")) { @Html.AntiForgeryToken() @Html.ValidationSummary(true) //... } }最满意答案
正如@MikeSmithDev所提到的,你不能把表单放在另一个表单中。 一种替代方案是AJAX迷你形式到控制器。 或者将它放在大表格之外并使用CSS使其“看起来正确”。
As @MikeSmithDev mentioned, you can't put a form inside another form. One alternative is to AJAX the mini-form to the controller. Or put it outside the big form and use CSS to make it "look right".
更多推荐
发布评论