ASP 101 - Active Server Pages 101 - Web01
The Place ASP Developers Go!

Please visit our partners


Windows Technology Windows Technology
15 Seconds
4GuysFromRolla.com
ASP 101
ASP Wire
VB Forums
VB Wire
WinDrivers.com
internet.commerce internet.commerce
Partners & Affiliates














ASP 101 is an
internet.com site
ASP 101 is an internet.com site
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

ASP 101 News Flash ASP 101 News Flash





ASP Source Code:
<%
' Tell the script to continue running if an error occurs:
On Error Resume Next
Dim objWinHttp
Dim strHTML
Set objWinHttp = Server.CreateObject("WinHttp.WinHttpRequest.5.1")
' Syntax:
'   .SetTimeouts(ResolveTimeout, ConnectTimeout, SendTimeout, ReceiveTimeout)
' The parameters are integers and specify the number of milliseconds to wait
' before timing out.  For a detailed description checkout the documentation:
' http://msdn2.microsoft.com/en-us/library/aa384061.aspx
' The defaults are:
'   objWinHttp.SetTimeouts 0, 60000, 30000, 30000
' Which means there is no timeout on name resolution, a 60 second timeout on
' connecting to the remote server, and 30 seconds each for sending the request
' and receiving the response.
' Depending on the timeouts you actually want it would probably look something
' more like this:
'   objWinHttp.SetTimeouts 5000, 5000, 10000, 10000
' That's 5 seconds each to resolve and connect and 10 seconds each for the
' request and response.
' Since I'm trying to illustrate what happens when timeouts expire,
' I'm setting ridiculously low 1ms timeouts so that it's guaranteed to break:
objWinHttp.SetTimeouts 1, 1, 1, 1
objWinHttp.Open "GET", "http://www.yahoo.com/", False
objWinHttp.Send
' Check if an error occured:
If Err.Number <> 0 Then
	' If you want, you can actually vary your processing based
	' on the actual error.  If you've implemented some sort of
	' caching, the best thing to do might be to fall back to
	' the previously cached version, but that really all depends
	' on your application.
	If Err.Number = -2147012894 Then
		strHTML = "A Timeout Error Occurred:" & vbCrLf
	Else
		strHTML = "An Unknown Error Occurred:" & vbCrLf
	End If
	strHTML = strHTML & "Error Source: " & Err.Source & vbCrLf
	strHTML = strHTML & "Error Number: " & Err.Number & vbCrLf
	strHTML = strHTML & "Error Description: " & Err.Description
	' If you'll be doing any further error checking then you
	' should clear the error object.
	Err.Clear
Else
	strHTML = objWinHttp.ResponseText	
End If	
Set objWinHttp = Nothing
%>
<p><strong>Here's The Code:</strong></p>
<table border="1">
<tr><td>
<pre>
<%= Server.HTMLEncode(strHTML) %>
</pre>
</td></tr>
</table>

Back the the Sample Output

Back to the Sample Index


Home |  News |  Samples |  Articles |  Lessons |  Resources |  Forum |  Links |  Search |  Feedback

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers