Error: 'System.NotSupportedException' for SecurityProtocol on IIS

Last Reply on Oct 06, 2016 08:05 AM By dharmendr

Posted on Oct 06, 2016 07:17 AM

hi,

 

i have configured paypal on my server and added these lines to enabl tls requested by paypal in my application

 

but when i open the page it gives me following error

 

https://snag.gy/fh587e.jpg

what should i do  Please advice
  ServicePointManager.Expect100Continue = true;
        ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
        ServicePointManager.DefaultConnectionLimit = 9999;

        //end of server protocal

        //Post back to either sandbox or live
        string strSandbox = "https://www.sandbox.paypal.com/cgi-bin/webscr";


        //post of live
        string strLive = "https://www.paypal.com/cgi-bin/webscr";



        HttpWebRequest req = (HttpWebRequest)WebRequest.Create(strSandbox);
        //Set values for the request back
        req.Method = "POST";
        req.ContentType = "application/x-www-form-urlencoded";
        byte[] param = Request.BinaryRead(HttpContext.Current.Request.ContentLength);
        string strRequest = Encoding.ASCII.GetString(param);
        string strResponse_copy = strRequest;  //Save a copy of the initial info sent by PayPal
        strRequest += "&cmd=_notify-validate";
        req.ContentLength = strRequest.Length;

        //for proxy
        //WebProxy proxy = new WebProxy(new Uri("http://url:port#"));
        //req.Proxy = proxy;
        //Send the request to PayPal and get the response
        StreamWriter streamOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII);
        streamOut.Write(strRequest);
        streamOut.Close();
        StreamReader streamIn = new StreamReader(req.GetResponse().GetResponseStream());
        string strResponse = streamIn.ReadToEnd();
        streamIn.Close();

        if (strResponse == "VERIFIED")
        {
}

 

You are viewing reply posted by: dharmendr on Oct 06, 2016 08:05 AM.
Posted on Oct 06, 2016 08:05 AM

This namespace already present. You need to select SecurityProtocolType and press F12 you will able to see the enum. Check the availe protocoltype in the system dll and you can use those only in your code.