O
octavio.filipe
Hi,
I'm trying to use the following code:
HttpWebRequest webRequest = WebRequest.Create(LOGIN_URL) as HttpWebRequest;
webRequest.CookieContainer = new CookieContainer();
HttpWebResponse webResponse = (HttpWebResponse) webRequest.GetResponse();
This code let me get the cookie (cookie PHPSESSID) I need, from
webResponse.
I will need this cookie to get the page that i really need.
Now I will copy the cookie to the HttpWebRequest that i will use to get the
real needed page:
HttpWebRequest httpWebRequestLogin =
HttpWebRequest.Create(LOGIN_URL_LOGIN) as HttpWebRequest;
httpWebRequestLogin.CookieContainer = new CookieContainer();
//note: webResponse.Cookies[0] have the PHPSESSID cookie (i know this)
httpWebRequestLogin.CookieContainer.Add(webResponse.Cookies[0]);
httpWebRequestLogin.Method="POST";
httpWebRequestLogin.ContentType="application/x-www-form-urlencoded";
StreamWriter requestWriter = new StreamWriter
(httpWebRequestLogin.GetRequestStream());
requestWriter.Write(data);
requestWriter.Close();
//lets try to get the page
HttpWebResponse httpWebResponseLogin =
(HttpWebResponse) httpWebRequestLogin.GetResponse();
The page didn't come out! Because the cookie PHPSESSID wasn't on the
httpWebRequestLogin, I think!
So what in the name of LORD am I doing wrong (in the process of copying the
cookie from the webResponse to the httWebRequestLogin)?
Please help me...
Thanks on advance,
o.f
I'm trying to use the following code:
HttpWebRequest webRequest = WebRequest.Create(LOGIN_URL) as HttpWebRequest;
webRequest.CookieContainer = new CookieContainer();
HttpWebResponse webResponse = (HttpWebResponse) webRequest.GetResponse();
This code let me get the cookie (cookie PHPSESSID) I need, from
webResponse.
I will need this cookie to get the page that i really need.
Now I will copy the cookie to the HttpWebRequest that i will use to get the
real needed page:
HttpWebRequest httpWebRequestLogin =
HttpWebRequest.Create(LOGIN_URL_LOGIN) as HttpWebRequest;
httpWebRequestLogin.CookieContainer = new CookieContainer();
//note: webResponse.Cookies[0] have the PHPSESSID cookie (i know this)
httpWebRequestLogin.CookieContainer.Add(webResponse.Cookies[0]);
httpWebRequestLogin.Method="POST";
httpWebRequestLogin.ContentType="application/x-www-form-urlencoded";
StreamWriter requestWriter = new StreamWriter
(httpWebRequestLogin.GetRequestStream());
requestWriter.Write(data);
requestWriter.Close();
//lets try to get the page
HttpWebResponse httpWebResponseLogin =
(HttpWebResponse) httpWebRequestLogin.GetResponse();
The page didn't come out! Because the cookie PHPSESSID wasn't on the
httpWebRequestLogin, I think!
So what in the name of LORD am I doing wrong (in the process of copying the
cookie from the webResponse to the httWebRequestLogin)?
Please help me...
Thanks on advance,
o.f