Re: HttpWebRequest/Response with e-mail attachments

From: Joerg Jooss (joerg.jooss_at_gmx.net)
Date: 08/31/04


Date: Tue, 31 Aug 2004 22:51:05 +0200

tomer wrote:
> Joerg,
>
> Thanks for the tip, it turned out to be rather useful.
> I managed to see what's the difference between my request and IE's
> request. I turns out that IE sends the request with a cookie, which I
> can't seem to find anywhere, guess it's the login cookie...
> If I copy the cookie from fiddler's IE request and send my request
> with it, it all goes well.
> Now I only need to find a way to get this cookie.
> D'you know any method of extracting cookies out of pages? am I even
> in the right direction?

That's why I asked whether you're using an empty CookieContainer with your
initial request ;-)

You have to create an CookieContainer for your request, otherwise there will
be no cookies in the response:

HttpWebRequest firstRequest = (HttpWebRequest) WebRequest.Create(url);
firstRequest.CookieContainer = new CookieContainer();
HttpWebResponse firstResponse = (HttpWebResponse)
firstRequest.GetResponse();

HttpWebRequest secondRequest = (HttpWebRequest) WebRequest.Create(url);
secondRequest.CookieContainer = new CookieContainer();
CookieCollection cookies = firstResponse.Cookies;
secondRequest.CookieContainer.Add(cookies);

Cheers,

-- 
Joerg Jooss
joerg.jooss@gmx.net 


Relevant Pages

  • HttpWebRequest with java session id cookie; HELP PLEASE
    ... I'm trying to login to a backend system running Java/Tomcat. ... HttpWebRequest with the login data and do a POST. ... HttpWebRequest with a new cookie container and add the java session id ... HttpWebRequest request = WebRequest.Create; ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: HttpWebRequest with java session id cookie; HELP PLEASE
    ... >> create a HttpWebRequest with the login data and do a POST. ... >> HttpWebResponse also contains a java session id cookie. ... >> session id cookie to the request: ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: HTTPModule - an interceptor indeed, but without communication skills!
    ... httpModule to check in the certain event before request has been processed ... easily manually append such querystring to bypass the validation. ... My suggestion is what about the cookie? ... In the validation code, you can use javascript ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Printing website - cookies
    ... would be requested with the Print command so that the latest version of any ... gets that cookie). ... At the request of any "private" article or image, ... All "private" images in the article turn out, on paper, as the default ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • Re: Problem with Forms Authentication cookies
    ... > only 2, the ASP.NET_SessionID cookie and the Forms Authentication cookie, ... > The next request coming is is a GET request for the Forms Authentication ... > In looking at the logs for NORMAL expired authentication redirects these ...
    (microsoft.public.dotnet.framework.aspnet.security)

Loading