0

I am trying to change cookie from WebClient to HttpClient in my code on vb.net. I need to convert this method using HttpClient. Here is my code using WebClient:

Public Class CookieWebClient
Inherits WebClient

Private cc As New CookieContainer()
Private lastPage As String
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)
            .CookieContainer = cc
            If Not lastPage Is Nothing Then
                .Referer = lastPage
            End If
        End With
    End If
    lastPage = address.ToString()
    Return R
End Function

End Class

Abe
  • 23
  • 5

0 Answers0