aspnet / Diagnostics

[Archived] Diagnostics middleware for reporting info and handling exceptions and errors in ASP.NET Core, and diagnosing Entity Framework Core migrations errors. Project moved to https://github.com/aspnet/AspNetCore
Apache License 2.0
213 stars 111 forks source link

DeveloperExceptionPageMiddleware always returns HTML, sometimes JSON would be better #346

Closed tjrobinson closed 6 years ago

tjrobinson commented 7 years ago

We're using the DeveloperExceptionPageMiddleware and it would be really useful if it could be changed/configured so that AJAX requests to APIs, e.g. from an Angular application were given a JSON response back instead of HTML. This would make the response much more readable when using F12 tools or testing the API through other non-browser tools like Postman.

I hope that's enough information to make sense, let me know if not.

There's a similar problem discussed here: http://stackoverflow.com/questions/35245893/mvc-6-webapi-returning-html-error-page-instead-of-json-version-of-exception-obje

Thanks!

davidfowl commented 7 years ago

Feels like we could do this as part of the new API work @rynowak.

/cc @Eilon

rynowak commented 7 years ago

https://tools.ietf.org/html/rfc7807

And then you want formatters and get bit by the layering bug 😆

aspnet-hello commented 6 years ago

This issue was moved to aspnet/Home#2590