C#与服务器建立会话,获取SessionId(临时cookie值)
public static string GetSessionId(string URL)
{
WebRequest wrt;
wrt = WebRequest.Create(URL);
WebResponse wrp;
wrp = wrt.GetResponse();
string html = new StreamReader(wrp.GetResponseStream(), Encoding.UTF8).ReadToEnd();
return wrp.Headers.Get("Set-Cookie");
}