httpwebrequence cookie problem
- From: "octavio.filipe" <0245078402@xxxxxxxxxx>
- Date: Thu, 19 May 2005 09:44:20 -0700
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
.
- Follow-Ups:
- Re: httpwebrequence cookie problem
- From: Feroze [msft]
- Re: httpwebrequence cookie problem
- Prev by Date: HTTP Network Programming Issue
- Next by Date: Re: C# very optimisation
- Previous by thread: HTTP Network Programming Issue
- Next by thread: Re: httpwebrequence cookie problem
- Index(es):
Relevant Pages
|
Loading