简体   繁体   English

C#HTTP获取响应标头丢失

[英]C# HTTP get response headers are missing

I am trying to make a HTTP get request in C# and get it's headers, because one of them is important for my application. 我试图在C#中发出HTTP获取请求并获取其标头,因为其中之一对于我的应用程序很重要。

I can see with Wireshark, that the headers are arrived properly. 我可以通过Wireshark看到标题正确到达。

My application looks like this: 我的应用程序如下所示:

HttpWebRequest wrGETURL = (HttpWebRequest)WebRequest.Create(sURL);
wrGETURL.Method = "HEAD";
wrGETURL.Headers.Add("UserServerIdent", "2");
WebResponse response = wrGETURL.GetResponse();
for (int i = 0; i < response.Headers.Count; i++)
{
    Console.WriteLine(response.Headers.GetKey(i));
}

It lists these headers only: Vary, Content-Type, Date, Server, X-Powered-By 它仅列出以下标头:Vary,Content-Type,Date,Server,X-Powered-By

However in WireShark I can see Location and some others too. 但是在WireShark中,我也可以看到Location和其他一些位置。

Do anyone know why I can't see the other headers? 有人知道为什么我看不到其他标题吗? Or maybe I should try to get the headers in some other ways? 还是我应该尝试以其他方式获取标题?

did you tried fiddler web debugger? 您是否尝试过提琴手网络调试器?

http://fiddler2.com http://fiddler2.com

there you can also see headers and much more.. 在那里您还可以看到标题和更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM