mvc 4 web api添加自定义响应http头(mvc 4 web api add custom response http header)

编程入门 行业动态 更新时间:2024-10-26 10:27:00
mvc 4 web api添加自定义响应http头(mvc 4 web api add custom response http header)

我们可以在默认响应头旁边添加额外的http响应头项目示例“Last Updated”吗?

我打电话时的示例(请求): 本地主机:12345 / API /的GetInfo 带标题: 主机:localHost:12345 ...... 那么api将用(Response)回复标题: HTTP / 1.1 200 OK 内容长度:XX 内容类型:XXX Last-Update:从API函数中生成的值和值

Can we add the extra http response header item example "Last Updated" beside the default response header?

example when I call (Request): localHost:12345/API/GetInfo with header: Host: localHost:12345 ...... then the api will reply the header with(Response): HTTP/1.1 200 OK Content-Length: XX Content-Type: XXX Last-Update: The value and the value generate from the API function

最满意答案

您可以使用此代码添加标题:

HttpContext.Current.Response.AppendHeader("Last-Update", value);

You can add header by using this code:

HttpContext.Current.Response.AppendHeader("Last-Update", value);

更多推荐

本文发布于:2023-08-07 04:13:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1459757.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自定义   api   mvc   web   http

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!