RE: Persistent https session?



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.
.



Relevant Pages

  • Re: NotificationSampleWebDav-Monitor OWA Inbox
    ... re-login or update your cookie with each response you get... ... Warning: Exiting Action with an exception: The remote server returned an ... // Create request object and assign credentials. ... Stream newStream = Request.GetRequestStream; ...
    (microsoft.public.exchange.applications)
  • Re: Problems with access to a web page
    ... Server: Apache ... Connection: close ... Look what I get now when I send the exact same request ... and got exactly the same 0 length response ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • Re: BASIC authentication Issues with IE - Part II - Solved but WHY?
    ... REQUEST and RESPONSE logging below to show you whats going on. ... using my local machine web server. ... However, at this point I am logged in and I have lots of links, one is a "who is online" link client?who.wcn, which I will open this up in a second window. ...
    (microsoft.public.inetserver.iis.security)
  • problem WebRequest and WebResponse
    ... I have a problem using HttpWebRequest so I wish somebody can help me. ... HttpWebRequest request = ... WebResponse response = null; ... connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: HTTP header processing sequence
    ... Initially it sends the request for the html source, and if there are any more objects to request it does so, and then wait for the server to reply sending back the requested data using appropriate headers. ... How does the (browser) client know how to match up multiple received responses from the server with GET-requests, as this does not appear to be sequential. ... So the association of request and response is no problem. ...
    (microsoft.public.win32.programmer.networks)