Closed ghost closed 4 years ago
I have attempted to build and use the 3.1 branch of Carter, which appears to have PR #220 's fix also applied. Unfortunately the issue still persists, it's as if the body is never read. It's entirely possible I am doing something wrong here, however this was a working pattern prior to 5.0.0.
If I add the following before the BindAndValidate call
context.Request.EnableBuffering();
context.Request.Body.Seek(0L, SeekOrigin.Begin);
var bodyString = new StreamReader(context.Request.Body).ReadToEndAsync().Result;
context.Request.Body.Seek(0L, SeekOrigin.Begin);
I can access the contents of bodyString just fine and it is correct.
Issue was specifically
public class LoginReq
{
public string Username;
public string Password;
}
It needs to be
public class LoginReq
{
public string Username { get; set; }
public string Password { get; set; }
}
Else JsonSerializer.Deserialize
With a simple client exercising the handling of parameters and responses
Passed through a boring nginx server and fowarded to
The result of BindAndValidate has null fields. The above dance does handle the new JSON serializer for responses, with the client having no issue. However, when breakpointing at the first test past BindAndValidate, the context has no sign of the submitted data and it will fail validation due to the fields being null.
This issue occurs on both dotnet 3.0 and 3.1.