Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

Fix FormTagHelper to make redudant Antiforgery token registration a no-op #4595

Closed
sebastienros opened this issue May 6, 2016 · 5 comments
Closed
Assignees
Milestone

Comments

@sebastienros
Copy link
Member

In a form generated from a tag helper, adding @Html.AntiforgeryToken() will result in this cryptic error that doesn't help:

An unhandled exception occurred while processing the request.

FormatException: The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.
System.Convert.FromBase64_Decode(Char* startInputPtr, Int32 inputLength, Byte* startDestPtr, Int32 destLength)

InvalidOperationException: The antiforgery token could not be decrypted.
Microsoft.AspNetCore.Antiforgery.Internal.DefaultAntiforgeryTokenSerializer.Deserialize(String serializedToken)
@rynowak
Copy link
Member

rynowak commented May 6, 2016

That just sounds like a bug, this shouldn't throw

@sebastienros sebastienros changed the title Better error message with extraneous @Html.AntiforgetryToken Better error message with extraneous @Html.AntiforgeryToken May 6, 2016
@dougbu
Copy link
Member

dougbu commented May 6, 2016

@sebastienros is your repro as simple as the following?

<form asp-action="Index">
  @Html.AntiforgeryToken()
</form>

If not, what else is needed?

Head-scratcher: The Html.AntiforgeryToken() call should be redundant.

@sebastienros
Copy link
Member Author

Exactly what I did.

@Eilon Eilon added this to the 1.0.0 milestone May 7, 2016
kichalla added a commit that referenced this issue May 12, 2016
[Fixes #4595] Better error message with extraneous @Html.AntiforgeryToken
kichalla added a commit that referenced this issue May 18, 2016
[Fixes #4595] Better error message with extraneous @Html.AntiforgeryToken
kichalla added a commit that referenced this issue May 20, 2016
[Fixes #4595] Better error message with extraneous @Html.AntiforgeryToken
@rynowak
Copy link
Member

rynowak commented May 20, 2016

@kichalla Can you rename this issue so that it shows up better in release notes

@kichalla kichalla changed the title Better error message with extraneous @Html.AntiforgeryToken Fix FormTagHelper to make redudant Antiforgery token registration a no-op May 20, 2016
@kichalla
Copy link
Member

Sure, done.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants