0
votes

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)
        //...
    }
}
1
You can't have a form inside a form. It's in the form element specification.MikeSmithDev
Ooouukey Thanks a lot, i spent hours with this error _ _", what i am trying to do is add a client through a mini-form inside a bigger form when the client doesn't exist. Well i try another way. Again Thanks a lot.Mugiwara
If you inspect the HTML as the browser interprets it, you'll probably find the 2nd form element has been removed. So you aren't posting where you think you are posting, which is probably giving the Antiforgery token conflict.MikeSmithDev
Yep... another way is only option!MikeSmithDev
Thanks again for the details ^^Mugiwara

1 Answers

4
votes

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".