Skip to content

HeaderNames now contains static readonly fields instead of const fields  #14901

Closed
@Tratcher

Description

@Tratcher

HeaderNames now contains static readonly fields instead of const fields

The static Microsoft.Net.Http.Headers.HeaderNames class contains string fields representing various common header names (e.g. HeaderNames.Origin). Starting in ASP.NET Core 3.0 Preview 5, these will change from const fields to static readonly fields.

See dotnet/aspnetcore#9514 for discussion.

Version introduced

3.0

Old behavior

These fields used to be const

New behavior

These fields are now static readonly.

Reason for change

The change prevents the values from being embedded across assembly boundaries allowing for value corrections as needed. It also enables faster reference equality checks.

Recommended action

Recompile against 3.0. Source code that used these fields as an attribute argument, a case in a switch statement, or when defining another constant will no longer be able to do so. To work around this break, developers can switch to using self-defined header name constants or string literals.

Category

  • ASP.NET Core

Affected APIs

All fields on Microsoft.Net.Http.Headers.HeaderNames


Issue metadata

  • Issue type: breaking-change

Metadata

Metadata

Assignees

Labels

breaking-changeIndicates a .NET Core breaking change

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions