HTTP Get Request - C#

HTTP Get Request - C#

code snippet

private static string Get(string strURL, string strUserAgent = "")
            string strResponseHtml = "";
                CookieContainer objCookieContainer = new CookieContainer();
                ServicePointManager.ServerCertificateValidationCallback += new RemoteCertificateValidationCallback(ValidateRemoteCertificate);
                HttpWebRequest objHttpWebRequest = null;
                HttpWebResponse objHttpWebResponse = null;
                objHttpWebRequest = (HttpWebRequest)WebRequest.Create(strURL);
                objHttpWebRequest.CookieContainer = objCookieContainer;
                objHttpWebRequest.KeepAlive = false;
                objHttpWebRequest.UserAgent = strUserAgent;
                objHttpWebResponse = (HttpWebResponse)objHttpWebRequest.GetResponse();
                strResponseHtml = new StreamReader(objHttpWebResponse.GetResponseStream()).ReadToEnd();
            catch (Exception ex) { strResponseHtml = ex.ToString(); }
            return strResponseHtml;

private static bool ValidateRemoteCertificate(
        object sender,
            System.Security.Cryptography.X509Certificates.X509Certificate certificate,
            System.Security.Cryptography.X509Certificates.X509Chain chain,
            System.Net.Security.SslPolicyErrors policyErrors
            return true;

"The best preparation for tomorrow is doing your best today"

Contact me!

Have questions? Feel free to use the form or send me an email with any questions.

I will be responsive to your requests and your questions.