title: TLS 1.2 httpwebrequest not working
body: <p>I have 3d Secure Payment System
  I want to send the data using HttpWebQuest and draw the result.
  Lucky data is not arriving. You need to reach via tls 1.2. Where am I making mistakes? Can you help?</p>
  
  <p>Sample Code ;</p>
  
  <pre><code>  System.Net.HttpWebResponse resp = null;
              try
              {
                  ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12;
                  System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(apiUrl);
                  string postdata = "DATA=" + xmlval.ToString();
                  byte[] postdatabytes = System.Text.Encoding.GetEncoding("ISO-8859-9").GetBytes(postdata);
                  request.Method = "POST";
                  request.ContentType = "application/x-www-form-urlencoded";
                  request.ContentLength = postdatabytes.Length;
                  System.IO.Stream requeststream = request.GetRequestStream();
                  requeststream.Write(postdatabytes, 0, postdatabytes.Length);
                  requeststream.Close();
                  ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12;
                  resp = (System.Net.HttpWebResponse)request.GetResponse();
                  System.IO.StreamReader responsereader = new System.IO.StreamReader(resp.GetResponseStream(), System.Text.Encoding.GetEncoding("ISO-8859-9"));
  
                  string responseXML = responsereader.ReadToEnd(); //Response read as XML string
  
                  System.Xml.XmlDocument response = new System.Xml.XmlDocument();
                  response.LoadXml(responseXML);    //string parsed as XML document
  
                  System.Xml.XmlNodeList list = response.GetElementsByTagName("Response");
                  ltrResponse.Text = list[0].InnerText;
  
                  list = response.GetElementsByTagName("AuthCode");
                  ltrAuthCode.Text = list[0].InnerText;
  
                  list = response.GetElementsByTagName("HostRefNum");
                  ltrHostRefNum.Text = list[0].InnerText;
  
                  list = response.GetElementsByTagName("ProcReturnCode");
                  ltrProcReturnCode.Text = list[0].InnerText;
  
                  list = response.GetElementsByTagName("TransId");
                  ltrTransId.Text = list[0].InnerText;
  
                  list = response.GetElementsByTagName("ErrMsg");
                  ltrErrMsg.Text = list[0].InnerText;
  
                  if (ltrProcReturnCode.Text == "99")
                  {
                      lblPaymentResult.Text = "Ödeme Başarısız.";
                      lblPaymentResult.ForeColor = System.Drawing.Color.Red;
                  }
                  else if (ltrProcReturnCode.Text == "00")
                  {
                      lblPaymentResult.Text = "Ödeme Başarılı";
                      lblPaymentResult.ForeColor = System.Drawing.Color.Green;
                  }
              }
              catch (Exception ex)
              {
                  lblPaymentResult.Text = "Bir Hata Oluştu : " + ex.ToString() + "";
                  lblPaymentResult.ForeColor = System.Drawing.Color.Red;
              }
              finally
              {
                  if (resp != null)
                  {
                      resp.Close();
                  }
              }
          }
          else
          {
              lblPaymentResult.Text = "3D Kimlik Doğrulaması Başarısız. Ödeme İsteği Gönderilemedi !";
              lblPaymentResult.ForeColor = System.Drawing.Color.Red;
          }
      }
  </code></pre>