Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Examples don't seem to work for .net 6 mvc web app #112

Open
sarchibald-mdsol opened this issue Feb 26, 2023 · 1 comment
Open

Examples don't seem to work for .net 6 mvc web app #112

sarchibald-mdsol opened this issue Feb 26, 2023 · 1 comment

Comments

@sarchibald-mdsol
Copy link

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();
@stevejgordon
Copy link
Owner

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants