Disable Browser Back Button using csharp

Disable Firefox and IE Back Button in Asp.net


public void ClearBrowserCache(){      HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache); 
HttpContext.Current.Response.Cache.SetExpires(DateTime.Now); HttpContext.Current.Response.Cache.SetExpires(DateTime.Now.AddSeconds(-1));
      HttpContext.Current.Response.Cache.SetNoStore();
     }

call this method in each and every page load Event.

note:This functionality will not work when you call Server.Transfer for page redirection.

The remote certificate is invalid

The remote certificate is invalid according to the validation procedure


you will get this error because of certificates issue while getting the response from the external web service or any other Web Request from the server.

follow the below snippet to resolve this issue

using System.Net;

using System.Net.Security;

using System.Security.Cryptography.X509Certificates;

protected void Page_Load(object sender, EventArgs e)

    {

      ServicePointManager.ServerCertificateValidationCallback = RemoteCertificateValidationCB;

      Uri uri = new Uri("http://microsoft.com");

      if (uri.Scheme == Uri.UriSchemeHttp)

     {

       HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri);

       request.Method = WebRequestMethods.Http.Get;

       HttpWebResponse response = (HttpWebResponse)request.GetResponse();

StreamReader reader = new StreamReader(response.GetResponseStream());     

       string tmp = reader.ReadToEnd();

Response.Write(tmp);

       response.Close();

               

     }

       

    }

public static bool RemoteCertificateValidationCB(Object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)

    {

        //If it is really important, validate the certificate issuer here.

        string resultsTrue = certificate.Issuer.ToString();

        //For now, accept any certificate

        return true;

    }