Open Kumodoushin opened 3 years ago
Hi @Kumodoushin! 👋🏻
Can you paste an example request and response? I just want to make sure the response is produced by the problem details middleware. As you've noticed, it's the AllowedHeaderNames
setting you should use to keep headers around when producing error responses.
Any updates on this? 😄
Sorry - too much stuff to do recently. Not sure if this is enough to satisfy your request - since these are postman screenshots and I'm new to this Valid request for comparison:
Thanks. Can I ask where the x-correlation-id is added to the response? What is the order of your middleware?
The header is added after ProblemDetails - as part of request logging middleware (Serilog with some enricher).
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseExceptionMiddleware(); //ProblemDetails is wrapped here
app.UseHttpsRedirection();
app.UseDefaultFiles();
app.UseStaticFiles();
app.UseRequestLogging(); //And logging (and adding the header) happens most likely here
app.UseSession();
app.UseRouting();
app.UseIdentityServer();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
In .net 5 webApi project with FluentValidation: When automatic model validation fails, custom header that was sent in request is cleared.
Would you kindly point out what am I missing?
configuration: