khellang / Middleware

Various ASP.NET Core middleware
MIT License
806 stars 110 forks source link

Disable ProblemDetailsResultFilter with condition like UseWhen (middleware) to support backwards compatibility #181

Open eholman opened 2 years ago

eholman commented 2 years ago

Is there a way to disable the functionality in the method OnResultExecuting of ProblemDetailsResultFilter so that the content will not be changed?

We're adding the conventions via AddProblemDetailsConventions but this changes all (existing) behavior. Since we're having existing functionality (an older V1 API) we're looking for a way to bypass the behavior in a dynamic way e.g. when Path (from Context.Request contains "/v1/".

Any thoughts on this one?

tibitoth commented 2 years ago

You can bypass the exception handling with this overload: https://github.com/khellang/Middleware/blob/master/src/ProblemDetails/ProblemDetailsOptions.cs#L208