getting the URL for the web page downloaded

  • Thread starter Thread starter Ian Emery
  • Start date Start date
I

Ian Emery

am using the following function to get the html page, assume i just use a
url such as http://www.acompany.com it gets the home page, that all works
fine, but how do I get the URL of what was downloaded page was such as
HTTP://WWW.ACOMPANY.COM/default.htm so it gives the name of the page
(default.htm)


Public Function GetPageHTMl(ByVal URL As String) As String
' Retrieves the HTML from the specified URL
Dim objWC As New System.Net.WebClient
Return New System.Text.UTF8Encoding().GetString( _
objWC.DownloadData(URL))

End Function
 
Hi,

Thanks for your post. As I understand, you want to get the redirected URL
of a downloaded page. Please correct me if there is any misunderstanding. I
recommend that you can use HttpWebResponse to get it as demonstrated in the
code snippet below:

Dim myReq As Net.HttpWebRequest = _
CType(Net.WebRequest.Create(URL ), Net.HttpWebRequest)
Dim myRes As Net.HttpWebResponse = myReq.GetResponse()
Dim sRedirectedURL As String = myRes.ResponseUri.AbsoluteUri

Hope this helps.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top