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);更多推荐
发布评论