Skip to content

Commit 2996e5c

Browse files
committed
Undo AntiforgeryStateProvider change
1 parent fb95f5c commit 2996e5c

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

src/Components/Shared/src/DefaultAntiforgeryStateProvider.cs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System.Diagnostics.CodeAnalysis;
5-
using System.Text.Json;
6-
using System.Text.Json.Serialization;
75
using Microsoft.AspNetCore.Components.Web;
86

97
namespace Microsoft.AspNetCore.Components.Forms;
@@ -26,19 +24,11 @@ public DefaultAntiforgeryStateProvider(PersistentComponentState state)
2624
// don't have access to the request.
2725
_subscription = state.RegisterOnPersisting(() =>
2826
{
29-
var bytes = JsonSerializer.SerializeToUtf8Bytes(
30-
GetAntiforgeryToken(),
31-
DefaultAntiforgeryStateProviderJsonSerializerContext.Default.AntiforgeryRequestToken);
32-
state.PersistAsJson(PersistenceKey, bytes);
27+
state.PersistAsJson(PersistenceKey, GetAntiforgeryToken());
3328
return Task.CompletedTask;
3429
}, RenderMode.InteractiveAuto);
3530

36-
if (state.TryTakeFromJson<byte[]>(PersistenceKey, out var bytes))
37-
{
38-
_currentToken = JsonSerializer.Deserialize(
39-
bytes,
40-
DefaultAntiforgeryStateProviderJsonSerializerContext.Default.AntiforgeryRequestToken);
41-
}
31+
state.TryTakeFromJson(PersistenceKey, out _currentToken);
4232
}
4333

4434
/// <inheritdoc />
@@ -47,6 +37,3 @@ public DefaultAntiforgeryStateProvider(PersistentComponentState state)
4737
/// <inheritdoc />
4838
public void Dispose() => _subscription.Dispose();
4939
}
50-
51-
[JsonSerializable(typeof(AntiforgeryRequestToken))]
52-
internal sealed partial class DefaultAntiforgeryStateProviderJsonSerializerContext : JsonSerializerContext;

0 commit comments

Comments
 (0)