日期:2014-05-17  浏览次数:20495 次

C# winform 如何获得header信息!!
在下想通过.net开发的web程序给C#winform程序传递参数,(link) 
以达到某种启动效果 
比如登陆名啊,程序运行参数啊之类的 
用微软的ClickOnce发布winform程序可以做到传参数,如http://ssss/xxx.application?a=1&b=2 
客户端可以获得对应的参数 
---------我想要实现的效果是不在后面传递参数,而是将信息保存在http://ssss/xxx.application 连接header中,我怎么样才可以取出这个header呢,程序中要怎么改造才可以实现呢 ,我对这个http header不是很了解,但是需要这么实现这个功能,忘高手帮帮忙!!!


------解决方案--------------------
C# code

/// <summary>
/// Returns the responded HTTP headers of the given URL.
/// </summary>
/// <param name="Url">The adress.</param>
/// <returns>List of headers</returns>
public Dictionary<string, string> GetHTTPResponseHeaders(string Url)
{
    Dictionary<string, string> HeaderList = new Dictionary<string, string>();
 
    WebRequest WebRequestObject = HttpWebRequest.Create(Url);
    WebResponse ResponseObject = WebRequestObject.GetResponse();
 
    foreach (string HeaderKey in ResponseObject.Headers)
        HeaderList.Add(HeaderKey, ResponseObject.Headers[HeaderKey]);
 
    ResponseObject.Close();
 
    return HeaderList;
}Snippet information
Author:
Jonas John 

License:
Public domain 

Language:
C# 

Created:
10/30/2007 

Updated:
10/30/2007 

Tags:
http, network 




// Retrieve headers:
Dictionary<string, string> Headers = GetHTTPResponseHeaders("http://www.jonasjohn.de/");
 
// And output them:
foreach (string HeaderKey in Headers.Keys) 
    Console.WriteLine("{0}: {1}", HeaderKey, Headers[HeaderKey]);

------解决方案--------------------
是http header节点中的值吗?比如:
C# code

//你看看你准备用那个

HtmlMeta
HtmlLink
HtmlGenericControl