dotnet / dotnet/AspNetCore.Docs.Samples
Antiforgery integration for minimal APIs
- Lingua principale
- C#
- Stelle
- 225
- Fork
- 170
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
See [Antiforgery integration for minimal APIs](https://devblogs.microsoft.com/dotnet/asp-net-core-updates-in-dotnet-8-preview-7/#antiforgery-integration-for-minimal-apis)
and [this sample](https://github.com/dotnet/AspNetCore.Docs.Samples/blob/main/fundamentals/minimal-apis/samples/MyAntiForgery/Program.cs#L16-L17)
In [this code](https://github.com/dotnet/AspNetCore.Docs.Samples/blob/main/fundamentals/minimal-apis/samples/MyAntiForgery/Program.cs#L57) I pass in the action so
```
app.MapGet("/DisableAntiforgery", () =>
{
return Results.Content(MyHtml.html("/todo"), "text/html");
});
app.MapGet("/post2", () =>
{
return Results.Content(MyHtml.html("/todo2"), "text/html");
});
```
Can use the same HTML when they pass in the action arg.
Is there a clean way to do this to pass in an arg for
```
```
Maybe that makes things too messy. Perhaps I should duplicate most of the HTML and not get the HTML from a method while passing the action.
```
public static string html2(string action, AntiforgeryTokenSet token) => $"""
""";
```
Works, but I'm not sure it's an improvement. There's no way to pass in a null token.
@sammychinedu2ky @david-acker
cc @guardrex
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Direzione di ricerca
Inizia dagli entry point referenziati di fundamentals/minimal-apis/samples/MyAntiForgery/Program.cs, soprattutto dalla generazione dell’HTML intorno alle righe 16–17 e 57. Confronta come l’argomento action e AntiforgeryTokenSet vengono passati al markup del form; il lavoro è completato quando l’esempio ha un approccio chiaro e manutenibile, senza una questione irrisolta relativa a un token null né HTML duplicato inutilmente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- csharp
- Ambito
- backend-api-design, documentation, security
- Tipo di issue
- Funzionalità
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100