0

I've created this sample using MSDN examples.

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);
}

Cannot get JSESSIONID. I need to make several GET/POST queries in one session, that's why I need JSESSIONID. Help me please.

Sergey Shafiev
  • 4,205
  • 4
  • 26
  • 37

1 Answers1

0
string cookieHeaderValue = ((System.Net.HttpWebResponse)response).Headers["Set-Cookie"].Split(new char[]{';'})[0].Trim();
andrewsi
  • 10,807
  • 132
  • 35
  • 51
MKD
  • 1