-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
area-middlewareIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlewaresIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlewareshelp wantedUp for grabs. We would accept a PR to help resolve this issueUp for grabs. We would accept a PR to help resolve this issue
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
The IExceptionHandlerFeature is not available in CustomizeProblemDetails when using "UseDeveloperExceptionPage". It is, however, available when using "UseExceptionHandler()". Is there a reason for this? It would be good to be able to customize the problem details also when using the DeveloperExceptionPage.
Expected Behavior
The IExceptionHandlerFeature is available when using DeveloperExceptionPage
Steps To Reproduce
Try the "/" endpoint from swagger.
using Microsoft.AspNetCore.Diagnostics;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddProblemDetails(configure =>
configure.CustomizeProblemDetails = (context) =>
{
if (context.HttpContext.Features.Get<IExceptionHandlerFeature>() is IExceptionHandlerFeature exceptionHandlerFeature)
{
Console.WriteLine("This will not print when using UseDeveloperExceptionPage()");
}
}
);
var app = builder.Build();
app.UseDeveloperExceptionPage();
app.UseSwagger();
app.UseSwaggerUI();
app.MapGet("/", () =>
{
throw new Exception();
});
app.Run();
Exceptions (if any)
No response
.NET Version
7.0.201
Anything else?
No response
Metadata
Metadata
Assignees
Labels
area-middlewareIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlewaresIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlewareshelp wantedUp for grabs. We would accept a PR to help resolve this issueUp for grabs. We would accept a PR to help resolve this issue