Skip to content

Issue when paired with Microsoft.AspNetCore.Mvc.Versioning #134

@rheone

Description

@rheone

When pairing StackExchange.Exceptional.AspNetCore 2.0.0-rc2.* with Microsoft.AspNetCore.Mvc.Versioning 2.2.0 and configuring versioning to ReportApiVersions will throw System.InvalidOperationException: Headers are read-only, response has already started when attempting, and failing, to access the the exceptional page / task.

I'm not sure if this is directly an issue with Exceptional, or with how Microsoft.AspNetCore.Mvc.Versioning is handling headers.

here is my configuration:

public class Startup
{
   // ... other unimportant configuration
   public IServiceProvider ConfigureServices(IServiceCollection services)
   {
         // ... other service configuration
         services.AddExceptional(configuration.GetSection("Exceptional"));
         // ... configure MVC
         services.AddApiVersioning(options =>
                             {
                                options.AssumeDefaultVersionWhenUnspecified = true;
                                options.ReportApiVersions = true;   // when set to true reporting api versions conflicts with StackExchange.Exceptional
                                options.DefaultApiVersion = new ApiVersion(1, 0);
                                options.ApiVersionReader = new HeaderApiVersionReader("api-version");
                             });
         // ... other service configuration
   }                             
}

setting ReportApiVersions to true will

... When this property is set to true, the HTTP headers "api-supported-versions" and "api-deprecated-versions" will be added to all valid service routes...

e.g. response header are modified, and Exceptional begins to fail

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions