Skip to content

AntiForgery vs. PartialCache #523

Open
@c9mb

Description

@c9mb

Umbraco Forms requires the use of Html.AntiForgeryToken() inside the form, presumably so a hidden field with the request verification token can be matched against the session cookie token.

This is all fine and well except that it won't play nice with PartialCache use, where the form may well be cached, and I see lots of people struggling with this one - PartialCache or AntiForgeryToken - pick one.

We have a fairly typical environment where admins can add forms to pages on an ad-hoc basis, and those pages are largely cached for performance, so it becomes unpredictable when the antiforgery token will get cached, and then break the submit validation.

You can add Html.AntiForgeryToken() to a designated non-cached section of a page, and the hidden field and cookie tokens will be added, but Umbraco-Forms will only work with it being a hidden form-field, and throws an error if it's not included in the form. i.e. you need to include Html.AntiForgeryToken() inside the form, which immediately causes a problem if the form has been cached.

It would be nice of you could tell the form to find and use the hidden token field on the page, rather than just assume the hidden form-field, and point it to something you know is not cached, while allowing the form itself to be cached.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions