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 108 forks source link

UseDeveloperExceptionJson middelware #477

Closed peirens-bart closed 6 years ago

peirens-bart commented 6 years ago

I would like to propose a new feature for this libary, UseDeveloperExceptionJson(). A middelware that is doeing the same thing as UseDevelopeExceptionPage() but returns Json.

I think the extension needs a routing filter so the middleware can deside what to return. this would be handy when creating an SPA where the api calls would return json. Now I got html in the F12 tools when I have an exception during development. I know that Unit Testing must solve most of the exception, but what if you forget the register a dependency. Finding the reason in the F12 tools when the return body is html is not so handy. As for now I have my own middleware that is doing something like that, but it can be handy as it was in the same namespace and assembly.

the Configure method can do something like:

if (env.IsDevelopment()) { app.UseDeveloperExceptionJson("*/api/*"); app.UseDeveloperExceptionPage(); }

Tratcher commented 6 years ago

Duplicate of https://github.com/aspnet/Home/issues/2573