Closed larssonsun closed 4 years ago
@larssonsun would you be able to provide a scenario to replicate this? I'm not sure I'm following. Thank you.
I'm afraid I should apologize for my issue.
i use autowrapper and Marvin.Cache.Headers at the same proj,
If middleware is used in the following order it will cause autowrapper to throw an exception that cannot be caught:
part of startup.cs:
` ...
app.UseApiResponseAndExceptionWrapper(new AutoWrapperOptions { ShowStatusCode = true });
app.UseResponseCaching();
app.UseHttpCacheHeaders();
app.UseRouting();
...
`
it will throw the exception:
Cannot access a closed Stream.
Middleware must be used in the following order:
` app.UseResponseCaching(); app.UseHttpCacheHeaders(); app.UseApiResponseAndExceptionWrapper(new AutoWrapperOptions { ShowStatusCode = true }); app.UseRouting();
`
and after this every thing is fine.
thank you for your reply.
@larssonsun Thank you for confirming that. :)
I'll looking into the exception message to JSON thing. I'll keep you posted.
By the way, Have you tried passing a ValidationError object to display Model errors instead of passing it as a string as a message in ApiException object?
ApiException(IEnumerable<ValidationError> errors, int statusCode = 400)
@larssonsun - One more thing. would you be able to open a new issue for the Exception message not recognizing JSON so I can close this thread to avoid mixing things up? Thanks!
part of the .proj:
... `