Web Request Query

DekaFlash

Well-known member
Joined
Feb 14, 2006
Messages
117
Programming Experience
1-3
Using Vb.net 2003, I have a variable declared as type WebRequest.


If the URI the Web Request is accessing is currently unavailable for
whatever reason, what will be returned by GetResponse.
Thanks,
Boulent
 
GetResponse will not return, but an exception will be raised that you can Try-Catch for.
 
Well you can do something like this;
VB.NET:
[COLOR=green]'1st declare th request object and set up timeout method of the WebRequest object[/COLOR]
objRequest.Timeout = TimeoutSeconds * 1000 
[COLOR=green]' Retrieve data from request ... declare response object and stuff
[/COLOR]{....}
[COLOR=green]' Check if available so, close the response[/COLOR] 
If Not objResponse Is Nothing Then 
     objResponse.Close() 
End If 
Catch 
[COLOR=green]' Error occured grabbing data so, simply return nothing[/COLOR] 
[COLOR=blue]Return[/COLOR] [COLOR=blue]String[/COLOR].Empty 
MessageBox.Show("No data received")

HTH
Regards ;)
 
Back
Top