From 49de15fef53a45d8eb86d33859a28fac7803241e Mon Sep 17 00:00:00 2001 From: Rick Anderson <3605364+Rick-Anderson@users.noreply.github.com> Date: Wed, 11 Oct 2023 14:44:40 -1000 Subject: [PATCH] IForm post /2 --- .../IFormFile/IformPost/IformPost.csproj | 9 ++++++++ .../samples/IFormFile/IformPost/Program.cs | 23 +++++++++++++++++++ .../IFormFile/IformPost/appsettings.json | 9 ++++++++ 3 files changed, 41 insertions(+) create mode 100644 fundamentals/minimal-apis/samples/IFormFile/IformPost/IformPost.csproj create mode 100644 fundamentals/minimal-apis/samples/IFormFile/IformPost/Program.cs create mode 100644 fundamentals/minimal-apis/samples/IFormFile/IformPost/appsettings.json diff --git a/fundamentals/minimal-apis/samples/IFormFile/IformPost/IformPost.csproj b/fundamentals/minimal-apis/samples/IFormFile/IformPost/IformPost.csproj new file mode 100644 index 0000000..1b28a01 --- /dev/null +++ b/fundamentals/minimal-apis/samples/IFormFile/IformPost/IformPost.csproj @@ -0,0 +1,9 @@ + + + + net8.0 + enable + enable + + + diff --git a/fundamentals/minimal-apis/samples/IFormFile/IformPost/Program.cs b/fundamentals/minimal-apis/samples/IFormFile/IformPost/Program.cs new file mode 100644 index 0000000..8380e4e --- /dev/null +++ b/fundamentals/minimal-apis/samples/IFormFile/IformPost/Program.cs @@ -0,0 +1,23 @@ +using Microsoft.AspNetCore.Mvc; + +var builder = WebApplication.CreateBuilder(); + +builder.Services.AddAntiforgery(); + +var app = builder.Build(); + +//app.UseAntiforgery(); + +app.MapPost("/upload", ([FromForm] DocumentUpload document) => +{ + return Results.Ok(); +}); + +app.Run(); + +public class DocumentUpload +{ + public string Name { get; set; } = "Uploaded Document"; + public string? Description { get; set; } + public IFormFile? Document { get; set; } +} diff --git a/fundamentals/minimal-apis/samples/IFormFile/IformPost/appsettings.json b/fundamentals/minimal-apis/samples/IFormFile/IformPost/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/fundamentals/minimal-apis/samples/IFormFile/IformPost/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +}