From 4451f81e906972fe16162be9932b53dc53fe7770 Mon Sep 17 00:00:00 2001 From: Julian Verdurmen <304NotModified@users.noreply.github.com> Date: Wed, 13 May 2020 23:43:55 +0200 Subject: [PATCH] context.Request.EnableBuffering(); --- .../ASP.NET Core 3/ASP.NET Core 3 - VS2019/Startup.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/examples/ASP.NET Core 3/ASP.NET Core 3 - VS2019/Startup.cs b/examples/ASP.NET Core 3/ASP.NET Core 3 - VS2019/Startup.cs index f829224e..448b36bb 100644 --- a/examples/ASP.NET Core 3/ASP.NET Core 3 - VS2019/Startup.cs +++ b/examples/ASP.NET Core 3/ASP.NET Core 3 - VS2019/Startup.cs @@ -4,6 +4,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.HttpsPolicy; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; @@ -41,17 +42,23 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) } app.UseHttpsRedirection(); app.UseStaticFiles(); - app.UseRouting(); - app.UseAuthorization(); + // needed for ${aspnet-request-posted-body} with an API Controller. Must be before app.UseEndpoints + app.Use(async (context, next) => { + context.Request.EnableBuffering(); + await next(); + }); + app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); }); + + } } }