Home All Groups Group Topic Archive Search About

Test if file exists before displaying with XMLHTTP



Author
23 Mar 2006 11:01 AM
Giles
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)

Author
23 Mar 2006 11:27 AM
Slim
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




Show quote
"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)
>
Author
23 Mar 2006 12:24 PM
Anthony Jones
Show quote
"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

AddThis Social Bookmark Button