CORS: Incorrect Status Code for OPTIONS endpoint #36592
Merged
Merged
Conversation
Copilot
AI
changed the title
[WIP] Update ASP.NET Core web hosting documentation
Initial analysis plan for issue #36526
Jan 8, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the CORS documentation to correct the expected HTTP status code returned when an ASP.NET Core CORS preflight (OPTIONS) request is denied, aligning the article with observed middleware behavior and the linked issue report.
Changes:
- Updated two statements in the CORS article to indicate denied preflight requests return
204 No Content(instead of200 OK). - Kept the existing guidance that denied preflight responses omit CORS headers, causing the browser to block the cross-origin request.
| * [Access-Control-Request-Headers](https://developer.mozilla.org/docs/Web/HTTP/Headers/Access-Control-Allow-Headers): A list of request headers that the app sets on the actual request. As stated earlier, this doesn't include headers that the browser sets, such as `User-Agent`. | ||
|
|
||
| If the preflight request is denied, the app returns a `200 OK` response but doesn't set the CORS headers. Therefore, the browser doesn't attempt the cross-origin request. For an example of a denied preflight request, see the [Test CORS](#testc6) section of this document. | ||
| If the preflight request is denied, the app returns a `204 No Content` response but doesn't set the CORS headers. Therefore, the browser doesn't attempt the cross-origin request. For an example of a denied preflight request, see the [Test CORS](#testc6) section of this document. |
tdykstra
approved these changes
May 12, 2026
wadepickett
reviewed
May 12, 2026
| * [Access-Control-Request-Headers](https://developer.mozilla.org/docs/Web/HTTP/Headers/Access-Control-Allow-Headers): A list of request headers that the app sets on the actual request. As stated earlier, this doesn't include headers that the browser sets, such as `User-Agent`. | ||
|
|
||
| If the preflight request is denied, the app returns a `200 OK` response but doesn't set the CORS headers. Therefore, the browser doesn't attempt the cross-origin request. For an example of a denied preflight request, see the [Test CORS](#testc6) section of this document. | ||
| If the preflight request is denied, the app returns a `204 No Content` response but doesn't set the CORS headers. Therefore, the browser doesn't attempt the cross-origin request. For an example of a denied preflight request, see the [Test CORS](#testc6) section of this document. |
Contributor
There was a problem hiding this comment.
@tdykstra , Line 250 uses an astrisk around the reponse and this ilne 367 uses backticks around the "returns a 204 No Content response". Should both cases use backticks?
wadepickett
approved these changes
May 12, 2026
Contributor
There was a problem hiding this comment.
@tdykstra, looks great! Only a minor item to look at regarding backticks around 204 No Content. Approved.
Update the date for the CORS documentation.
Replace asterisks with backticks for ` 204 new content` Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #36526
Internal previews