0

我使用 MSDN 示例创建了这个示例。

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(redirUri);
request.Method = "GET";
request.CookieContainer = new CookieContainer();
Trace.WriteLine("Created request to " + redirUri);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();

// Right here I want to get JSESSIONID, but Cookies are empty

foreach (Cookie cook in response.Cookies)
{
   Debug.WriteLine("{0} = {1}", cook.Name, cook.Value);
}

无法获取 JSESSIONID。我需要在一个会话中进行多个 GET/POST 查询,这就是我需要 JSESSIONID 的原因。请帮帮我。

4

1 回答 1

0
string cookieHeaderValue = ((System.Net.HttpWebResponse)response).Headers["Set-Cookie"].Split(new char[]{';'})[0].Trim();
于 2012-10-04T14:23:13.643 回答