Skip to content

[bug] HttpRequest.Headers becomes Read-Only #2176

Open
@bubrick

Description

@bubrick

Component

OpenTelemetry.Instrumentation.Wcf

Package Version

Package Name Version
OpenTelemetry.Instrumentation.AspNet 1.9.0-beta.1
OpenTelemetry.Instrumentation.Wcf 1.0.0-rc.17

Runtime Version

net48

Description

HttpRequest.Headers becomes read-only when OpenTelemetry packages are installed.
By default, System.Web does not make headers read-only for IIS7 requests, but AspNetParentSpanCorrector always makes it read-only

Steps to Reproduce

// global.asax.cs
protected void Application_BeginRequest(object sender, EventArgs e)
{
    Request.Headers.Set("MyExtraHeader", "hello-world");
}

Expected Result

Header added successfully when application is hosted in IIS

Actual Result

Collection is read-only.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NotSupportedException: Collection is read-only.

Additional Context

Seems to be introduced in this commit. Should probably check if the headers collection is already modifiable and take no action in such case, returning to the current behavior otherwise.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcomp:instrumentation.wcfThings related to OpenTelemetry.Instrumentation.Wcf

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions