Skip to content

Commit 5a081ab

Browse files
committed
Fix the antiforgey problem
1 parent f45ea1d commit 5a081ab

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

projects/.net8/minimal-api-form-model-binding/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
var builder = WebApplication.CreateBuilder();
55
builder.Services.AddAntiforgery();
66
var app = builder.Build();
7-
7+
app.UseAntiforgery();
88
app.MapGet("/", (HttpContext context, IAntiforgery antiforgery) =>
99
{
1010
var token = antiforgery.GetAndStoreTokens(context);
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
# Minimal API form model binding
22

3-
This sample demonstrates the ability to use `[FromForm]` binding in Minimal API.
3+
This sample demonstrates the ability to use `[FromForm]` binding in Minimal API.
4+
5+
6+
Note: This is broken in RC 2

projects/.net8/minimal-api-form-model-binding/minimal-api-form-model-binding.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,11 @@
66
<PreviewFeatures>true</PreviewFeatures>
77
<Nullable>enable</Nullable>
88
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="Microsoft.Net.Compilers.Razor.Toolset" Version="7.0.0-preview.23512.5">
12+
<PrivateAssets>all</PrivateAssets>
13+
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
14+
</PackageReference>
15+
</ItemGroup>
916
</Project>

0 commit comments

Comments
 (0)