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

Razor Pages map HEAD requests to GET handler #6155

Merged
merged 3 commits into from
May 1, 2018
Merged

Conversation

guardrex
Copy link
Collaborator

@guardrex guardrex commented May 1, 2018

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.

@guardrex guardrex requested a review from pranavkm May 1, 2018 18:48
}
```

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:
Copy link
Contributor

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.

Copy link
Collaborator Author

@guardrex guardrex May 1, 2018

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!?

}
```

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:
Copy link
Member

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


`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`:
Copy link
Member

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.

Copy link
Collaborator Author

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

Copy link
Collaborator Author

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.

.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.
Copy link
Member

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.

@guardrex
Copy link
Collaborator Author

guardrex commented May 1, 2018

ty @scottaddie

@guardrex guardrex removed the request for review from Rick-Anderson May 1, 2018 23:19
@guardrex guardrex merged commit b3d1784 into master May 1, 2018
@guardrex guardrex deleted the guardrex/rp-head branch May 1, 2018 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants