HTTPWebRequest (System.Net)

This is derived from the WebRequest abstract class


The following line of code does not work and generates the following error message
"Option Strict On disallows implicit conversions from System.Net.WebRequest" to "System.Net.HttpWebRequest"

objHttpWebRequest = New System.Net.HttpWebRequest.Create("url") 

You should use the following line instead
objHttpWebRequest = TryCast(System.Net.HttpWebRequest.Create("url"),System.Net.HttpWebRequest)


Dim objHttpWebRequest As System.Net.HttpWebRequest 

With objHttpWebRequest
   .Method = "GET"
   .TimeOut = 10000
   .MaximumAutomaticRedirections = 200
   .Credentials = New System.Net.NetworkCredential("userid", "password")
   .Credentials = New System.Net.NetworkCredential("userid", "password","INTRANET")
   .ContentType = "text/xml"
End With

With objHttpWebRequest
   .Method = "POST"
   .TimeOut = Cint(System.Timespan.FromMinutes(5).TotalMilliseconds)
   .Credentials = System.Net.CredentialCache.DefaultCredentials
   .ContentLength =
End With






© 2019 Better Solutions Limited. All Rights Reserved. © 2019 Better Solutions Limited TopPrevNext