1

I want to send out a POST with a specific certificate using WebClient. Request you to kindly help. I want something like this.

Dim  myWebClient As New WebClient()
mywebclient.ClientCertificates.Add(new X509Certificate()
Dim responseArray1 As Byte() = myWebClient.UploadValues(finalurl1, "POST", myNameValueCollection1)

Please help .

Matt Wilko
  • 26,994
  • 10
  • 93
  • 143
Gautam Kumar
  • 1,162
  • 3
  • 14
  • 29

1 Answers1

1

The answer is here: How can you add a Certificate to WebClient (C#)?

Converted to VB (untested):

Public Class MyWebClient
    Inherits WebClient

    Protected Overrides Function GetWebRequest(ByVal address As System.Uri) As System.Net.WebRequest
        Dim R = MyBase.GetWebRequest(address)
        If TypeOf R Is HttpWebRequest Then
            With DirectCast(R, HttpWebRequest)
                .ClientCertificates.Add(new X509Certificate())
            End With
        End If
        Return R
    End Function
End Class
Community
  • 1
  • 1
  • Thanks a lot Femiani..I got to know how to add certificate to webclient but I am not sure how to use this for executing someurl.i nned to execute something like this Dim responseArray1 As Byte() = myWebClient.UploadValues(someurl, "POST", myNameValueCollection1) – Gautam Kumar May 13 '14 at 11:00
  • @user3631589 This has already been answered here: http://stackoverflow.com/questions/8222092/sending-http-post-with-system-net-webclient. I highly recommend you search for the answers to your questions before asking repeats, you'll be amazed how much information is already out there. Good luck. – Thomas Femiani May 14 '14 at 04:43