I am setting up a pay by usage model and I’ve tried a global response filter but am not able to get at the length of the response (FrameResponseStream.get_Length not supported in dotnet core 2.1) so I’m left with serializing the dto and getting length but hoping for a more efficient method?
Can’t get a stack trace on a stack overflow easily, but if you put the response filter above in and then hit swagger-ui using the openapi plugin, you should get a repro. that response type does get a true on TypeSerializer.HasCircularReferences… Took me a long time to track down… work around is as follows:
// sliding session & bytes used
GlobalResponseFilters.Add((httpReq, res, responseDto) =>
{
var sess = res.Request.SessionAs<UserSession>();
if (!ServiceStack.Text.TypeSerializer.HasCircularReferences(responseDto))
{
sess.bytesUsed += ServiceStack.Text.JsonSerializer.SerializeToString(responseDto).Length;
}
res.Request.SaveSession(sess, TimeSpan.FromHours(hours));
});
PS: did repro both on core 2.1 mac as well as AWS ECS.