RE: Persistent https session?
- From: David Kirkland <DavidKirkland@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 19 Feb 2007 09:09:10 -0800
This is the reply I get from the server:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>302 Found</TITLE>
</HEAD><BODY>
<H1>Found</H1>
The document has moved <A HREF=" / " >here</A>.<P>
</BODY></HTML>
If I set the AllowAutoRedirect propert on the HttpWebRequest to true, the
app just hangs when doing the request.GetResponse().
As mentioned before I get this response every time the request is made. IE7
redirects the first time the page is requested, but gets the document on the
second request.
Thanks in advance!
"David Kirkland" wrote:
Hi, I am trying to connect to an https server and download a file. The server.
requires a client side certificate, which I have loaded successfully using
the X509Certificate class. I then add this certificate to the HttpWebRequest
class and connect to the server.
The problem arises because the initial request to the server gets a 302
redirect response. This response is OK, and is also recieved in IE7. The
second request in IE7 is not redirected, and I can download the file
successfully. However, if I try this from my C# client I get the redirect on
the first and second request. Is the SSL connection being renegotiated at
every request?
Code:
static HttpWebRequest GetHttpRequest()
{
X509Certificate cert = new X509Certificate(@"c:\cert.P12", "somePassword");
string url = "https://www.cdinternet.com/Reports/someTextFile.TXT";
Uri clearstream = new Uri(url);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(clearstream);
request.ClientCertificates.Add(cert);
request.Proxy = GetProxy();
request.AllowAutoRedirect = false;
request.ProtocolVersion = HttpVersion.Version10;
request.KeepAlive = true;
HttpRequestCachePolicy noCachePolicy = new
HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore);
request.CachePolicy = noCachePolicy;
request.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET
CLR 1.1.4322; .NET CLR 2.0.50727)";
request.PreAuthenticate = false;
request.Pipelined = true;
return request;
}
I am calling this method by:
request = GetHttpRequest();
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
stream = response.GetResponseStream();
.... process stream.....
... repeat the request...
request = GetHttpRequest();
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
stream = response.GetResponseStream();
.... process stream.....
Any advice would be welcome. If I have left out any necessary detail please
let me know.
Thanks,
David.
- Follow-Ups:
- RE: Persistent https session?
- From: David Kirkland
- RE: Persistent https session?
- Prev by Date: Re: dotnet 1.1 vs 2.0 (best replacement for List<int> in 1.1)
- Next by Date: retaining leading whitespace in text of an xml node
- Previous by thread: Create Printer Friendly using HTML
- Next by thread: RE: Persistent https session?
- Index(es):
Relevant Pages
|