Skip to content

Instantly share code, notes, and snippets.

@jglozano
Created January 21, 2022 22:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jglozano/d1ee76c2a644b9d21b7281d0cb9c6c93 to your computer and use it in GitHub Desktop.
Save jglozano/d1ee76c2a644b9d21b7281d0cb9c6c93 to your computer and use it in GitHub Desktop.
Reading Body from HttpRequest
// snippet around reading from HttpRequest.Body
var request = context.Request;
request.EnableBuffering();
// deserialize into temp structure using System.Text.Json.JsonSeralizer
var temp = await JsonSerializer.DeserializeAsync<RequestTemp>(request.Body,
options: new JsonSerializerOptions { PropertyNameCaseInsensitive = true });
request.Body.Seek(0, SeekOrigin.Begin);
return temp;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment