-
Notifications
You must be signed in to change notification settings - Fork 25.2k
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
Min API: How to modify headers in responses #34471
Comments
Notes: I should consider what we already have at: See HttpContext.Response.Headers in that section and example we use for both single and multiple values: // Set header with single value
httpContext.Response.Headers["ResponseHeaderName"] = "headerValue";
// Set header with multiple values
string[] responseHeaderValues = new string[] { "headerValue1", "headerValue1" };
httpContext.Response.Headers["ResponseHeaderName"] = responseHeaderValues; In this Min API doc under the Example Return values section, after the string return values example I might consider adding something like this: Modifying Headers app.MapGet("/", (HttpContext context) => {
context.Response.Headers["X-Custom-Header"] = "CustomValue";
return "Hello World";
}); |
Notes: This topic is also on the high traffic list for topics that need to be updated as part of the freshness effort. Maske sure I update the date after addressing this issue and reviewing the topic as a whole. Also see open issue on this topic: #33588 |
Hello @wadepickett if you want I can add your example to the "Minimal Apis quick reference" page (this issue). I would suggest to also include it on the Create responses page as it is very similar. However, instead of adding it behind the string examples, I was thinking to create a new sub-header. About the review and refresh, I think there's no new features released in 9.0 that can be added to these pages. |
@timdeschryver, sounds great! A new sub section seems right for this. I was not putting this on my plate to think through any further until next sprint when I had time to take it on given other high priority work we are trying to wrap up, so I just made these initial notes after looking it over a few minutes in triage. I think your suggestions are great. If you want to take on this one, it is really appreciated. |
Description
UUF verbatim:
Page URL
https://learn.microsoft.com/en-us/aspnet/core/fundamentals/minimal-apis?view=aspnetcore-9.0
Content source URL
https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/fundamentals/minimal-apis.md
Document ID
b09824ab-b051-75a1-13b7-b0e281cc46e0
Article author
@Rick-Anderson
Metadata
Related Issues
Associated WorkItem - 371158
The text was updated successfully, but these errors were encountered: