problem in getting html source code in asp.net
-
Hi to all, i had use this code for got html source of any page for downloading purpuse, but now i have faces a problem when i run my application then some time this function don't return html source. In my application i am using a loop for getting html source code for 10 page so i write a while loop and call this function GetHtmlSource for html source now when i debug it then seen that randamly leave one or two page which is not getting html source code if i run two times then it leave diffrent page on both time not same page so i don't understand why this could happen, where as i send right url all time within loop. if any body have any clue plz send ASAP. i need it urgent plz. Public Function GetHtmlSource(ByVal url As String) As String Dim objWebClient As New System.Net.WebClient Dim aRequestedHTML() As Byte Dim strRequestedHTML As String Try objWebClient.BaseAddress = System.String.Empty aRequestedHTML = objWebClient.DownloadData(url) Dim objUTF8 As New UTF8Encoding strRequestedHTML = objUTF8.GetString(aRequestedHTML) Return strRequestedHTML Catch ex As Exception strRequestedHTML = ex.Message End Try End Function thanks in advance arvind