IIS ASP - Test if file exists before displaying with XMLHTTP

This is Interesting: Free IT Magazines  
Home > Archive > IIS ASP > March 2006 > Test if file exists before displaying with XMLHTTP





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Test if file exists before displaying with XMLHTTP
Giles

2006-03-25, 11:58 am

I have a left menu that is accessed and displayed via XMLHTTP (it resides on
the same server). Some sections of the web site don't have a "menu.asp", so
a "Page Not Found" page is returned, which doesn't look great in the menu
column.. Is there a way to know if a page exists before using
xml.responseText to pull it?
(apart from checking the actual text of the returned page to see if it
contains error-like words)
Thanks
Giles
(PS using xmlhttp instead of server.execute as the menu-page needs
processing before displaying)


Slim

2006-03-25, 11:58 am

Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FileExists(filespec)) Then
msg = filespec & " exists."
Else
msg = filespec & " doesn't exist."
End If


if you do not know the physical path you can try this

Set pc = Server.CreateObject("MSWC.PermissionChecker")

pc.HasAccess(url)


if you have permissions the file must exist

I have not checked this, but its worth a try




"Giles" <giles@nospam.com> wrote in message
news:OkkGXjmTGHA.4976@TK2MSFTNGP11.phx.gbl...
>I have a left menu that is accessed and displayed via XMLHTTP (it resides
>on the same server). Some sections of the web site don't have a "menu.asp",
>so a "Page Not Found" page is returned, which doesn't look great in the
>menu column.. Is there a way to know if a page exists before using
>xml.responseText to pull it?
> (apart from checking the actual text of the returned page to see if it
> contains error-like words)
> Thanks
> Giles
> (PS using xmlhttp instead of server.execute as the menu-page needs
> processing before displaying)
>



Anthony Jones

2006-03-25, 11:58 am


"Giles" <giles@nospam.com> wrote in message
news:OkkGXjmTGHA.4976@TK2MSFTNGP11.phx.gbl...
> I have a left menu that is accessed and displayed via XMLHTTP (it resides

on
> the same server). Some sections of the web site don't have a "menu.asp",

so
> a "Page Not Found" page is returned, which doesn't look great in the menu
> column.. Is there a way to know if a page exists before using
> xml.responseText to pull it?
> (apart from checking the actual text of the returned page to see if it
> contains error-like words)
> Thanks
> Giles
> (PS using xmlhttp instead of server.execute as the menu-page needs
> processing before displaying)
>
>


Just test the XMLHTTP.Status property after attempting to fetch it. If it's
404 the file didn't exist and the responseText will contain the sites 404
content.

Anthony


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com