AntiForgery MachineKey错误是由于另一种形式内的形式?(AntiForgery MachineKey error due to form inside another form?

编程入门 行业动态 更新时间:2024-10-23 05:47:54
AntiForgery MachineKey错误是由于另一种形式内的形式?(AntiForgery MachineKey error due to form inside another form? MVC4)

是否有可能因为另一个表单中的表单而导致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".

更多推荐

本文发布于:2023-07-24 20:08:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1250561.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:形式   错误   是由于   MachineKey   AntiForgery

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!