[Breaking change]: Endpoints configured with 'MapFallbackToFile()' now only match 'HEAD' and 'GET' requests #495
Labels
7.0.0
Announcement
Breaking change
Documented
The breaking change has been published to the .NET Core docs
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'sConsumesAttribute
. This was an undesirable change in behavior from .NET 5 that we are partially addressing in .NET 7 by making fallback file endpoints only matchGET
andHEAD
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 matchHEAD
andGET
requests.Type of breaking change
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
orGET
, 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
orGET
, you can specify additional HTTP request methods usingWithMetadata()
. For example:Affected APIs
All overloads of
StaticFilesEndpointRouteBuilderExtensions.MapFallbackToFile()
.The text was updated successfully, but these errors were encountered: