You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've created a new .net6 mvc web app using vs2022 & the standard project template.
When I add via nuget the CorrelationId package, and modify program.cs and then run, my first page load shows:
The 'X-Correlation-ID' request header is required, but was not found.
Here's my code ...
builder.Services.AddDefaultCorrelationId(options =>
{
options.CorrelationIdGenerator = () => Guid.NewGuid().ToString();
options.AddToLoggingScope = true;
options.EnforceHeader = true;
options.IgnoreRequestHeader = false;
options.IncludeInResponse = true;
options.RequestHeader = "My-Custom-Correlation-Id";
options.ResponseHeader = "X-Correlation-Id";
options.UpdateTraceIdentifier = false;
});
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseMigrationsEndPoint();
}
else
{
app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseCorrelationId();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
The text was updated successfully, but these errors were encountered:
@sarchibald-mdsol Are you including a header My-Custom-Correlation-Id in your request? With EnforceHeader=true, this is the expected behaviour if incoming requests do not include the header. I cannot reproduce an issue when the expected header is present.
I've created a new .net6 mvc web app using vs2022 & the standard project template.
When I add via nuget the CorrelationId package, and modify program.cs and then run, my first page load shows:
Here's my code ...
The text was updated successfully, but these errors were encountered: