-
Notifications
You must be signed in to change notification settings - Fork 25.3k
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
Razor Pages map HEAD requests to GET handler #6155
Conversation
aspnetcore/mvc/razor-pages/index.md
Outdated
} | ||
``` | ||
|
||
If no HEAD handler (`OnHead`) is defined, Razor Pages falls back to calling the GET page handler (`OnGet`) in ASP.NET Core 2.1 or later. This behavior is opt-in with the [SetCompatibilityVersion method](xref:fundamentals/startup#setcompatibilityversion-for-aspnet-core-mvc) in `Startup.Configure` for ASP.NET Core 2.1→2.x: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guess it's a bit verbose to call this out, but precise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest that if we do do it we'll probably have less trouble with adoption/migration.
We're probably going to get slammed by reader remarks now that they go directly into docs repo issues. I humbly beseech the 🙏 server gods 🙏 for this approach to work and save us a few reader feedback issues of Why isn't this working!?
aspnetcore/mvc/razor-pages/index.md
Outdated
} | ||
``` | ||
|
||
If no HEAD handler (`OnHead`) is defined, Razor Pages falls back to calling the GET page handler (`OnGet`) in ASP.NET Core 2.1 or later. This behavior is opt-in with the [SetCompatibilityVersion method](xref:fundamentals/startup#setcompatibilityversion-for-aspnet-core-mvc) in `Startup.Configure` for ASP.NET Core 2.1→2.x: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This behavior is opt-in
Opt in to this behavior
aspnetcore/mvc/razor-pages/index.md
Outdated
|
||
`SetCompatibilityVersion` effectively sets the Razor Pages option `AllowMappingHeadRequestsToGetHandler` to `true`. The behavior is opt-in until the release of ASP.NET Core 3.0 preview 1 or later because each major version of ASP.NET Core adopts all of the patch release behaviors of the previous version. | ||
|
||
Global opt-in behavior for patch releases 2.1→2.x can be avoided with an app configuration that maps HEAD requests to the GET handler. Set the `AllowMappingHeadRequestsToGetHandler` Razor Pages option to `true` without calling `SetCompatibilityVersion` in `Startup.Configure`: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use a word instead of the → symbol. This will be safer for localization purposes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok ... but I wonder if the arrow predates written language! 😄 lol
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you mean the direction it points for right-to-left reading languages. Makes sense.
aspnetcore/mvc/razor-pages/index.md
Outdated
.SetCompatibilityVersion(Microsoft.AspNetCore.Mvc.CompatibilityVersion.Version_2_1); | ||
``` | ||
|
||
`SetCompatibilityVersion` effectively sets the Razor Pages option `AllowMappingHeadRequestsToGetHandler` to `true`. The behavior is opt-in until the release of ASP.NET Core 3.0 preview 1 or later because each major version of ASP.NET Core adopts all of the patch release behaviors of the previous version. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- preview 1 --> Preview 1
- Break this 2nd sentence into 2 sentences.
ty @scottaddie |
Fixes #6124
We may need to work on wording ... it's a bit tricky to concisely phrase the critical points. However, I do recommend that we go this direction. To merely describe the scenario and not (quickly) speak to the patch compat issue (with a link) will probably leave a lot of devs in a bad state.