Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then TitleL.Text = GetAccountInfoFromApi("test") End If End Sub Private Function GetAccountInfoFromApi(accountno As String) As String Dim accountInformationUrl As String = "/provider-data/api/1/metastore/schemas/dataset/items/avax-cv19" Dim webClient As Net.WebClient = New WebClient() 'Return webClient.DownloadString(New Uri(accountInformationUrl)) Dim retString As String Try retString = webClient.DownloadString(New Uri(accountInformationUrl)) Catch ex As WebException If ex.Status = WebExceptionStatus.ProtocolError AndAlso ex.Response IsNot Nothing Then Dim resp = DirectCast(ex.Response, HttpWebResponse) If resp.StatusCode = HttpStatusCode.NotFound Then ' HTTP 404 'other steps you want here End If End If 'throw any other exception - this should not occur Throw End Try Return retString End Function
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)