I am trying to deploy PayPal application to IIS.
I cannot connect to PayPal due to issue with TLS1.2
I did all changes to the registry and using .Net 4.6.1
If I use this code on console application
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
using (var response = WebRequest.Create("https://tlstest.paypal.com/").GetResponse())
using (var streamReader = new StreamReader(response.GetResponseStream()))
{
Console.WriteLine(streamReader.ReadToEnd());
}
it works.
Same code put in asp.net application and deployed to IIS on the same server does not work.
Any ideas why console application is working and asp.net application deployed on IIS is not?
Error:
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 104.75.235.58:443 Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 104.75.235.58:443
Source Error:
Line 16: System.Net.ServicePointManager.SecurityProtocol = System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls; Line 17: Line 18: using (var response = WebRequest.Create("https://tlstest.paypal.com/").GetResponse()) Line 19: using (var streamReader = new StreamReader(response.GetResponseStream())) Line 20: {
Source File: C:\WebApplication2\WebApplication2\WebForm1.aspx.cs Line: 18
Stack Trace:
[SocketException (0x274c): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 104.75.235.58:443] System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) +185 System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) +506
[WebException: Unable to connect to the remote server] System.Net.HttpWebRequest.GetResponse() +1390 WebApplication2.WebForm1.Page_Load(Object sender, EventArgs e) in C:\Temp\Razno\PPtest\WebApplication2\WebApplication2\WebForm1.aspx.cs:18 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51 System.Web.UI.Control.OnLoad(EventArgs e) +95 System.Web.UI.Control.LoadRecursive() +59 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +678
Console.WriteLine
will not work in asp.net application. Can you please provide code for us, how you did it in asp.net app – Victor Leontyev