Created
January 21, 2022 22:24
-
-
Save jglozano/d1ee76c2a644b9d21b7281d0cb9c6c93 to your computer and use it in GitHub Desktop.
Reading Body from HttpRequest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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