I'm trying to get body from request of an authorization class (AuthorizationHandler), but that body is a Stream and after reading your content, the post request that comes on next can not be executed because Stream content has been disposable.
I'm using this code to get Stream content:
protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, Autorizacao requirement)
{
var routeValues = context.Resource as AuthorizationFilterContext;
if (routeValues != null)
{
var obj = StreamToObject(routeValues.HttpContext.Request.Body);
context.Succeed(requirement);
}
return Task.FromResult(0);
}
private Object StreamToObject(Stream stream)
{
try
{
string content;
using (var reader = new StreamReader(stream))
content = reader.ReadToEnd();
return Newtonsoft.Json.JsonConvert.DeserializeObject(content);
}
catch (Exception e)
{
throw e;
}
}
How i can do to workaround this problem ?