[英]How to get all headers from HttpListenerResponse .NET core
I have a HttpListenerResponse which Headers array only contains 2 entries.我有一个 HttpListenerResponse,其中 Headers 数组仅包含 2 个条目。 The entire content of the HttpListenerResponse is seen in this picture HttpListenerResponse 的全部内容见这张图
I'm testing my HttpListener by using Postman.我正在使用 Postman 测试我的 HttpListener。 In my postman Response I see the following headers:在我的 postman 响应中,我看到以下标题:
As you can see the Server and Date headers are present in the response but not in my HttpListenerResponse content.如您所见,响应中存在 Server 和 Date 标头,但我的 HttpListenerResponse 内容中没有。 Why are they not there and how can I get them?为什么他们不在那里,我怎样才能得到他们?
Im not a.Net expert, but when i tried to create an API Gateway i had the same problem.我不是 .Net 专家,但是当我尝试创建 API 网关时,我遇到了同样的问题。 For me, to be able to access all the headers in Net Core, i had to use the interface IHeaderDictionary of Microsoft.AspNetCore.Http package.对我来说,为了能够访问 Net Core 中的所有标题,我必须使用 Microsoft.AspNetCore.Http package 的接口 IHeaderDictionary。 The headers will be a property of HttpContext.Request object.标头将是 HttpContext.Request object 的属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.