According to your description, I suggest you could add this line inside the gloal.asax file or ure it in a function, at the starting line.
Liket this:
Imports System.Net
Imports System.Web.Optimization
Public Class MvcApplication
Inherits System.Web.HttpApplication
Protected Sub Application_Start()
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
AreaRegistration.RegisterAllAreas()
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters)
RouteConfig.RegisterRoutes(RouteTable.Routes)
BundleConfig.RegisterBundles(BundleTable.Bundles)
End Sub
End Class
Best Regards,
Brando
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
PublicSharedFunction processCCRequest(ByVal strRequest AsString)AsString'declare the web request object and set its path to the PayTrace APIDim ThisRequest As WebRequest = WebRequest.Create("https://beta.paytrace.com/api/default.pay")'configure web request object attributes
ThisRequest.ContentType ="application/x-www-form-urlencoded"
ThisRequest.Method ="POST"'encode the requestDim Encoder AsNew System.Text.ASCIIEncoding
Dim BytesToSend AsByte()= Encoder.GetBytes(strRequest)'declare the text stream and send the request to PayTrace's APIDim StreamToSend As Stream = ThisRequest.GetRequestStream
StreamToSend.Write(BytesToSend,0, BytesToSend.Length)
StreamToSend.Close()ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.TlsDim TheirResponse As HttpWebResponse = ThisRequest.GetResponse
Dim sr AsNew StreamReader(TheirResponse.GetResponseStream)Dim strResponse AsString= sr.ReadToEnd
sr.Close()Return strResponse
EndFunction
Member
269 Points
2879 Posts
How do you establish a TLS 1.2 connection
Jun 18, 2018 10:32 PM|Jackxxx|LINK
Can anyone please explain how to establish a TLS 1.2 connection using VB.NET? My site is on a Win 2012 R2 server and is targeting .Net 4.5.
Where does this code get added (web.config/global.asax or other or set to use TLS 1.2
Jackxxx
Star
9831 Points
3120 Posts
Re: How do you establish a TLS 1.2 connection
Jun 20, 2018 06:59 AM|Brando ZWZ|LINK
Hi Jackxxx,
According to your description, I suggest you could add this line inside the gloal.asax file or ure it in a function, at the starting line.
Liket this:
Imports System.Net Imports System.Web.Optimization Public Class MvcApplication Inherits System.Web.HttpApplication Protected Sub Application_Start() ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 AreaRegistration.RegisterAllAreas() FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters) RouteConfig.RegisterRoutes(RouteTable.Routes) BundleConfig.RegisterBundles(BundleTable.Bundles) End Sub End Class
Best Regards,
Brando
Member
10 Points
8 Posts
Re: How do you establish a TLS 1.2 connection
Dec 18, 2018 05:35 AM|Rahil Saxena|LINK