Thursday, March 22, 2012

Check if External Image Url valid/exist

Hi,
I would like to check if the external image url is valid, if it is not valid
i would like to show another external "not available" image from an alternate
url. Any idea how do do it or any function that i can use?
i have added a vb function is the custom code to be called to check if the
url is valid, it works great in report designer preview, however after i
deployed, in the report manager all the image return an "not available" image
from an alternate url, regardless if the url is valid.
Below is the VB function that i added into the custom code:
Function IsValid(ByVal Url As String) As Boolean
Dim sStream As IO.Stream
Dim URLReq As Net.HttpWebRequest
Dim URLRes As Net.HttpWebResponse
Try
URLReq = Net.WebRequest.Create(Url)
URLRes = URLReq.GetResponse()
sStream = URLRes.GetResponseStream()
Dim reader As String = New IO.StreamReader(sStream).ReadToEnd()
Return True
Catch ex As Exception
Return False
End Try
End FunctionPlease can someone answer my question'? Thanks
"SL" wrote:
> Hi,
> I would like to check if the external image url is valid, if it is not valid
> i would like to show another external "not available" image from an alternate
> url. Any idea how do do it or any function that i can use?
> i have added a vb function is the custom code to be called to check if the
> url is valid, it works great in report designer preview, however after i
> deployed, in the report manager all the image return an "not available" image
> from an alternate url, regardless if the url is valid.
> Below is the VB function that i added into the custom code:
> Function IsValid(ByVal Url As String) As Boolean
> Dim sStream As IO.Stream
> Dim URLReq As Net.HttpWebRequest
> Dim URLRes As Net.HttpWebResponse
> Try
> URLReq = Net.WebRequest.Create(Url)
> URLRes = URLReq.GetResponse()
> sStream = URLRes.GetResponseStream()
> Dim reader As String = New IO.StreamReader(sStream).ReadToEnd()
> Return True
> Catch ex As Exception
> Return False
> End Try
> End Functionsql

No comments:

Post a Comment