We've offered you several different solutions for determining whether files
exist. Each one comes with its own particular limitations or ideal-use
conditions. The MSWC.Tools object is a good choice if you're checking for the
existence of a file within the context of your own local root Web site. The
FileSystemObject object, on the other hand, is good for checking for a file
located anywhere on your physical file system (or in shares available to the Web
user). We've also shown you a quick client-side approach for determining whether
image files exist on any Web server, but the technique is intended for the
client computer and applies, for the most part, just to images. Suppose you want
to check for the existence or availability of a Web page on any arbitrary
server. For instance, you might want to create an ASP page of your favorite
links, but you want to make sure, on the server, programmatically, that each one
exists and is currently available before you show it to your end users. The
following code snippet demonstrates how you can use the MSXML library's
ServerXMLHTTP object to carry out this task. Note: You'll need version 3.0 or
later of the MSXML library to use this code.<%
'Timeout values in milliseconds
lngResolveTimeout = 500
lngConnectTimeout = 500
lngSendTimeout = 500
lngReceiveTimeout = 500
strTestUrl = "http://www.microsoft.com/nonexistingpage.html"
Set objHttpRequest = CreateObject("MSXML2.ServerXMLHTTP")
With objHttpRequest
.SetTimeouts lngResolveTimeout, lngConnectTimeout, lngSendTimeout,
lngReceiveTimeout
.Open "GET", strTestUrl
.Send
Select Case .Status
Case 200 'No problem!
Response.Write strTestUrl &
" is a valid, available URL"
Case 404 'Not found
Response.Write strTestUrl &
" could not be found (404 Error)"
Case Else 'Some other problem
Response.Write "An
unexpected HTTP Status value was returned: " &
.Status
End Select
End With
Set objHttpRequest = Nothing
%>
Determine whether a url exists
By ElementK Journals, published on 18 Jul 2001
| Filed in
You might also like...
ASP (3.0) forum discussion
-
Invitation to take part in an academic research study
by researchlab (0 replies)
-
How to insert & edit unique value using store procedure
by umeshdaiya (0 replies)
-
How to troubleshoot Epson laser printer?
by daisywyatt618 (0 replies)
-
view state is stored after the page post-back
by shriniwas.khatri852 (0 replies)
-
Transfer selected rows from one GridView to another GridView in aspxform(ASP.NET)
by dorsa (0 replies)
ASP (3.0) podcasts
-
Hanselminutes: Startup Series: Buying an Existing Small Company or Online Application
Published 8 years ago, running time 0h34m
Scott talks to Rob Walling about how he purchases small niche products and companies online and revitalizes them. He recently purchased an existing product that consisted of a 300 gig database and tens of thousands of lines of Classic ASP. How did he know it was valuable? What's next?
Comments