httpwebrequence cookie problem



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
.



Relevant Pages

  • Re: Getting properties of file on web server without downloading it
    ... yes it's a HTTP server. ... I was issuing a HttpWebRequest for the file, ... Dim loginCookie as New Cookie ...
    (microsoft.public.inetsdk.programming.webbrowser_ctl)
  • Re: overriding GetWebRequest and GetWebResponse
    ... "Piotr Kochanowski" wrote in ... I need to add cookie support to webservice client on PocketPC (not ... > HttpWebRequest req = base.GetWebRequest; ... > the site says I need CF SP1, so I downloaded and installed it (but I could ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: cookie-based authentication with HttpWebRequest
    ... but I'm stuck trying to figure ... say you have some sort of page of customizable content - an example ... The best approach to understand how a web applicaton works and how to control it remotely with HttpWebRequest is to track a browser-based session using a debugging proxy like Fiddler and then program a sequence of HttpWebRequests accordingly. ... If you have already a persistent cookie on disk, you may even get away with an unmanaged call to InternetGetCookie, and add it to your HttpWebRequest's CookieContainer. ...
    (microsoft.public.dotnet.general)
  • Re: Internet/Web classes in .NET/VC++...
    ... The path is part of the cookie. ... If I use the C++ WebClient class, I can successfully get the end results. ... The Web interface to the database is not .NET, SOAP, or any 'standard' interface, and uses formatting that the WebClient class doesn't like - it reformats the queries so that the database end chokes on the more complicated queries. ... So, I tried the HTTPWebRequest class. ...
    (microsoft.public.dotnet.languages.vc)
  • Re: Internet class differences...
    ... HTTPWebRequest (which submits the query successfully but seems unable ... to submit the cookie and sequence number properly to retrieve the ... WebCLient orders the header values slightly differently (the same ...
    (microsoft.public.dotnet.general)

Loading