VB.Net在WebBrowser使用CookieContainer中的cookies的方法

Private Class CookieAwareWebClient
	Inherits WebClient
	Public Sub New()
		CookieContainer = New CookieContainer()
	End Sub
	Public Property CookieContainer() As CookieContainer
		Get
			Return m_CookieContainer
		End Get
		Private Set
			m_CookieContainer = Value
		End Set
	End Property
	Private m_CookieContainer As CookieContainer
	Protected Overrides Function GetWebRequest(address As Uri) As WebRequest
		Dim request = MyBase.GetWebRequest(address)
		Dim httpRequest = TryCast(request, HttpWebRequest)
		If httpRequest IsNot Nothing Then
			httpRequest.CookieContainer = CookieContainer
		End If
		Return request
	End Function
End Class
Private Sub Form1_Load(sender As Object, e As EventArgs)
	Using client = New CookieAwareWebClient()
		client.Proxy.Credentials = CredentialCache.DefaultNetworkCredentials
		client.DownloadData("http://blog.lishewen.com")
		Dim cookies = client.CookieContainer.GetCookies(New Uri("http://blog.lishewen.com"))
		Dim prefCookie = cookies("PREF")
		webBrowser1.Navigate("http://blog.lishewen.com", "", Nothing, ("Cookie: " & Convert.ToString(prefCookie.Value)) + Environment.NewLine)
	End Using
End Sub