Skip to content

Conversation

javiercn
Copy link
Member

@javiercn javiercn commented Aug 22, 2025

Paired with dotnet/sdk#50420


Fix ETag header not found error for compressed resources in Release builds

Description

When running ASP.NET Core applications with compressed static web assets in Release configuration, the runtime throws an InvalidOperationException with message "ETag header not found".

We removed the additional ETag in production because some servers experience issues with it. For development, we switched to emit the ETag only in the Debug configuration.

The runtime however depended on the ETag being present for development scenarios and when we removed it, it started causing issues with dotnet run -c Release.

The fix removes the usage of weak ETags for .NET 10.0 and onwards, replacing it with an original-resource endpoint property. The SDK will continue to emit weak ETags for .NET 9.0 for backwards compatibility.

Fixes #63364

@github-actions github-actions bot added the needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically label Aug 22, 2025
@javiercn javiercn requested a review from maraf August 22, 2025 12:16
@javiercn
Copy link
Member Author

/backport to release/10.0.1xx-rc2

Copy link
Contributor

Started backporting to release/10.0.1xx-rc2: https://github.com/dotnet/aspnetcore/actions/runs/17157590098

Copy link
Contributor

@javiercn an error occurred while backporting to "release/10.0.1xx-rc2", please check the run log for details!

Error: The specified backport target branch "release/10.0.1xx-rc2" wasn't found in the repo.

@javiercn
Copy link
Member Author

/backport to release/10.0-rc2

Copy link
Contributor

Started backporting to release/10.0-rc2: https://github.com/dotnet/aspnetcore/actions/runs/17157614755

Copy link
Contributor

@javiercn an error occurred while backporting to "release/10.0-rc2", please check the run log for details!

Error: The specified backport target branch "release/10.0-rc2" wasn't found in the repo.

@javiercn javiercn added feature-static-web-assets area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlewares and removed needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically labels Aug 22, 2025
@javiercn
Copy link
Member Author

/backport to release/10.0-rc1

Copy link
Contributor

Started backporting to release/10.0-rc1: https://github.com/dotnet/aspnetcore/actions/runs/17158160293

@javiercn javiercn marked this pull request as ready for review August 22, 2025 15:40
@Copilot Copilot AI review requested due to automatic review settings August 22, 2025 15:40
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors how static asset descriptors are linked between compressed and uncompressed versions by replacing ETag-based lookup with an "original-resource" property. This change improves the reliability of finding the original asset for compressed variants during development.

Key changes:

  • Replaced ETag-based linking with property-based linking using "original-resource" property
  • Removed weak ETag handling and simplified ETag response headers
  • Added descriptor mapping for efficient lookup during development

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
StaticAssetsIntegrationTests.cs Updated test manifest creation to use "original-resource" property instead of weak ETag
StaticAssetDevelopmentRuntimeHandler.cs Refactored asset linking logic from ETag-based to property-based lookup with new descriptor mapping

@javiercn
Copy link
Member Author

/backport to release/10.0

Copy link
Contributor

Started backporting to release/10.0: https://github.com/dotnet/aspnetcore/actions/runs/17174851658

@lewing lewing merged commit b8a8adf into main Aug 25, 2025
29 checks passed
@lewing lewing deleted the javiercn/use-property-for-original-resource-runtime branch August 25, 2025 19:54
@dotnet-policy-service dotnet-policy-service bot added this to the 11.0-preview1 milestone Aug 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlewares feature-static-web-assets
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ETag header not found error when running release build of app with compressed resources
3 participants