views:

29

answers:

1

I have created a web application that calls a web service that requires a Client Certificate for authentication. Here is a snippet of how I am building the request:

            // Grab Certificate
            X509Certificate2 cert2 = new X509Certificate2(AppDomain.CurrentDomain.BaseDirectory + GiftCardConfig.A2A_CertificateLocation, GiftCardConfig.A2A_CertificatePassword, X509KeyStorageFlags.MachineKeySet);

            // First Call Status Account
            StringBuilder urlStatus = new StringBuilder(GiftCardConfig.A2A_URL + "webservice.asp?");
            urlStatus.Append("userid=" + GiftCardConfig.A2A_UserID);
            urlStatus.Append("&pwd=" + GiftCardConfig.A2A_Password);
            urlStatus.Append("&sourceid=" + GiftCardConfig.A2A_SourceID);
            urlStatus.Append("&cardnum=" + cardNumber);
            urlStatus.Append("&purseno=" + GiftCardConfig.A2A_PurseID);

            urlStatus.Append("&status=ACTIVATE");

            // Build HTTP Request
            HttpWebRequest wrStatus = (HttpWebRequest)WebRequest.Create(urlStatus.ToString());
            wrStatus.KeepAlive = true;
            wrStatus.Method = "GET";
            wrStatus.Accept = "text/xml";
            wrStatus.UserAgent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.2; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 1.0.3705; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E)";
            wrStatus.ClientCertificates.Clear();
            wrStatus.ClientCertificates.Add(cert2);

This all works, but only intermittenly. About every 24 hours the Server hosting the web service returns a 403:Forbidden error. The only way to fix it is to do a iisreset of the server running the web application. We are completely stumped about this issue and would like to know if this issue has something to do with the web application or the configuration of the server it is being hosted on.

Any possible solutions or comments are greatly appreciated!

+1  A: 

Hi Larry, you could try setting keep alive to false, though there may be a performance hit with this. Cheers Tigger

Tigger