Re: HTTP Network Programming Issue
- From: "Feroze [msft]" <ferozed@xxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 19 May 2005 16:00:10 -0700
If I unerstand you correctly, you are saying that you cannot get to a site
which requires Cookie, Authentication and SSL at the same time, while going
through a proxy that also requires authentication.
If so, looking at your code below, I dont see you adding credential to the
HttpWebRequest object. You should set credentials on the HttpWebRequest as
well, otherwise your credentials wont be sent, and hence the request will
get denied with a 401.
--
feroze
-----------------
This posting is provided as-is. It offers no warranties and assigns no
rights.
See http://weblogs.asp.net/feroze_daud for System.Net related posts.
----------------
"bd-chan" <brentdsmith@xxxxxxxxx> wrote in message
news:1116520425.801933.64120@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> I'm trying to log in to a secured web site automatically using c#. To
> do this I have go through a proxy server, and use SSL, and log in to
> the secure site with another user name and password (different from the
> proxy user name and password).
>
> Now, I can get through the proxy by setting the correct credentials on
> the WebProxy. I can get through SSL by setting up a dummy certificate
> policy class that always returns true. If I go to a regular web site
> like http:\\www.google.com it works. If I go to SSL site
> (https:\\siteusingssl.com\) then it works. The problem occurs when
> trying to access the site that requires all three methods. The error
> returned is 401: Unauthorized. I think the site may use cookies, but I
> can't check the cookies returned in the response object because when I
> do the request.GetResponse() it always throws an exception and doesn't
> return a valid response object.
>
> If you've read this much, then you deserve to see the code of my most
> recent attempt:
>
> //Set Up The Proxy Server
> WebProxy proxy = new WebProxy("http://my.proxy.com:3128/", true);
> CredentialCache proxyCache = new CredentialCache() ;
> proxyCache.Add(new Uri("http://my.proxy.com:3128/"), "Basic", new
> NetworkCredential("user", "pw")) ;
> proxyCache.Add(new Uri("https://the.secured.com/"), "Basic", new
> NetworkCredential("user", "pw")) ;
>
> proxy.Credentials = proxyCache ;
> request = WebRequest.Create("https://the.secured.com") ;
> request.Proxy = proxy;
>
> //Set Up SSL
> ServicePointManager.CertificatePolicy = new CertPolicy();
>
> // Send the 'HttpWebRequest' and wait for response.
> HttpWebResponse response = (HttpWebResponse)request.GetResponse();
>
> Any help will be much appreciated.
>
> Thanks,
>
> Brent
>
.
- References:
- HTTP Network Programming Issue
- From: bd-chan
- HTTP Network Programming Issue
- Prev by Date: Re: httpwebrequence cookie problem
- Next by Date: RE: Datagrid: show new record row
- Previous by thread: Re: HTTP Network Programming Issue
- Next by thread: httpwebrequence cookie problem
- Index(es):
Relevant Pages
|