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

[Breaking change]: Endpoints configured with 'MapFallbackToFile()' now only match 'HEAD' and 'GET' requests #495

Open
1 of 3 tasks
MackinnonBuck opened this issue Oct 4, 2022 · 0 comments
Labels
7.0.0 Announcement Breaking change Documented The breaking change has been published to the .NET Core docs

Comments

@MackinnonBuck
Copy link
Member

Description

The ConsumesAttribute attribute allows controller actions to specify their supported content types. Starting in .NET 6, if a fallback file endpoint was configured, it could match routes that were discarded due to the request having a different content type than what was specified in an action's ConsumesAttribute. This was an undesirable change in behavior from .NET 5 that we are partially addressing in .NET 7 by making fallback file endpoints only match GET and HEAD requests.

Version

.NET 7 RC2

Previous behavior

Endpoints configured with StaticFilesEndpointRouteBuilderExtensions.MapFallbackToFile() may match requests made with any request method.

New behavior

Endpoints configured with StaticFilesEndpointRouteBuilderExtensions.MapFallbackToFile() will only match HEAD and GET requests.

Type of breaking change

  • Binary incompatible: Existing binaries may encounter a breaking change in behavior, such as failure to load/execute or different run-time behavior.
  • Source incompatible: Source code may encounter a breaking change in behavior when targeting the new runtime/component/SDK, such as compile errors or different run-time behavior.
  • Behavioral change: Existing code and binaries may experience different run-time behavior.

Reason for change

This partially reverts larger breaking change accidentally introduced in .NET 6. Since it's highly unusual to expect a fallback file response when making a request with a method other than HEAD or GET, we anticipate the impact of this breaking change to be minimal.

Recommended action

If you want fallback file endpoints to match requests with methods other than HEAD or GET, you can specify additional HTTP request methods using WithMetadata(). For example:

endpoints.MapFallbackToFile("index.html")
    .WithMetadata(new HttpMethodMetadata(new[] { /* List supported methods here */ }));

Affected APIs

All overloads of StaticFilesEndpointRouteBuilderExtensions.MapFallbackToFile().

@aspnet aspnet locked as resolved and limited conversation to collaborators Oct 4, 2022
@gewarren gewarren added the Documented The breaking change has been published to the .NET Core docs label Oct 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
7.0.0 Announcement Breaking change Documented The breaking change has been published to the .NET Core docs
Projects
None yet
Development

No branches or pull requests

2 participants