Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > objFSO.FileExists not working?????

Reply
Thread Tools

objFSO.FileExists not working?????

 
 
Rudi Ahlers
Guest
Posts: n/a
 
      04-10-2004
I have the following link: http://hobbit/newhp/index.asp?l=advert, and it
doesn't do what I want it to do, even though the file exists.
If a file doesn't exist, it should use home.asp as default, yet it uses
home.asp as default regardless if the file exists or not?
Here is the script:


linkname = request.QueryString("l")

if linkname <> "" then
page = linkname & ".html"
If objFSO.FileExists(page) = false Then
page = "home.asp"
End If
end if

If http://hobbit/newhp/index.asp?l=advert123 (which doesn't exist) it goes
to home.asp, which is what I want, but it also does it for all the files
that does exist, and reason for that?

--

Kind Regards
Rudi Ahlers
+27 (82) 926 1689

Greater love has no one than this, that he lay down his life for his friends
(John 15:13).


 
Reply With Quote
 
 
 
 
Steven Burn
Guest
Posts: n/a
 
      04-10-2004
Select Case linkname
Case ""
page = "home.asp"
Case else
page = linkname & ".html"
If objFSO.FileExists(page) = false Then
page = "home.asp"
else
page = page
End If
End Select

--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

Disclaimer:
I know I'm probably wrong, I just like taking part ;o)


Rudi Ahlers <SP4M_Rudi@SP4M_Bonzai.org.za_SP4M> wrote in message
news:HvadnSvs0ZcIruXdRVn-...
> I have the following link: http://hobbit/newhp/index.asp?l=advert, and it
> doesn't do what I want it to do, even though the file exists.
> If a file doesn't exist, it should use home.asp as default, yet it uses
> home.asp as default regardless if the file exists or not?
> Here is the script:
>
>
> linkname = request.QueryString("l")
>
> if linkname <> "" then
> page = linkname & ".html"
> If objFSO.FileExists(page) = false Then
> page = "home.asp"
> End If
> end if
>
> If http://hobbit/newhp/index.asp?l=advert123 (which doesn't exist) it goes
> to home.asp, which is what I want, but it also does it for all the files
> that does exist, and reason for that?
>
> --
>
> Kind Regards
> Rudi Ahlers
> +27 (82) 926 1689
>
> Greater love has no one than this, that he lay down his life for his

friends
> (John 15:13).
>
>



 
Reply With Quote
 
 
 
 
Bob Barrows
Guest
Posts: n/a
 
      04-10-2004
Rudi Ahlers wrote:
> I have the following link: http://hobbit/newhp/index.asp?l=advert,
> and it doesn't do what I want it to do, even though the file exists.
> If a file doesn't exist, it should use home.asp as default, yet it
> uses home.asp as default regardless if the file exists or not?
> Here is the script:
>
>
> linkname = request.QueryString("l")
>
> if linkname <> "" then
> page = linkname & ".html"
> If objFSO.FileExists(page) = false Then
> page = "home.asp"
> End If
> end if
>
> If http://hobbit/newhp/index.asp?l=advert123 (which doesn't exist) it
> goes to home.asp, which is what I want, but it also does it for all
> the files that does exist, and reason for that?


Where is the line of code that does the redirection?

Bob Barrows


--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


 
Reply With Quote
 
Lord Merlin
Guest
Posts: n/a
 
      04-10-2004
Bob, this is part of a table structure

<TR>
<TD WIDTH="160" HEIGHT="100%" ROWSPAN="3" BGCOLOR="#63526B">
<!--#include file="menu.html"--> </TD>
<TD HEIGHT="100%" ROWSPAN="3"><%=server.Execute(page)%></TD>
<TD WIDTH="25" HEIGHT="100%" ALIGN="RIGHT" VALIGN="TOP"
BACKGROUND="images/layout/r_b3.gif" BGCOLOR="#FFA531"><IMG
SRC="images/layout/r_b2.gif" WIDTH="25" HEIGHT="11"></TD>
</TR>


and all works fine is I don't include that part where it checks if the file
exist. But the moment I tell it to check if the file exsits, it doesn't seem
to play along nicely
--

Kind Regards
Rudi Ahlers
+27 (82) 926 1689

Greater love has no one than this, that he lay down his life for his friends
(John 15:13).
"Bob Barrows" <> wrote in message
news:...
Rudi Ahlers wrote:
> I have the following link: http://hobbit/newhp/index.asp?l=advert,
> and it doesn't do what I want it to do, even though the file exists.
> If a file doesn't exist, it should use home.asp as default, yet it
> uses home.asp as default regardless if the file exists or not?
> Here is the script:
>
>
> linkname = request.QueryString("l")
>
> if linkname <> "" then
> page = linkname & ".html"
> If objFSO.FileExists(page) = false Then
> page = "home.asp"
> End If
> end if
>
> If http://hobbit/newhp/index.asp?l=advert123 (which doesn't exist) it
> goes to home.asp, which is what I want, but it also does it for all
> the files that does exist, and reason for that?


Where is the line of code that does the redirection?

Bob Barrows


--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"



 
Reply With Quote
 
Egbert Nierop \(MVP for IIS\)
Guest
Posts: n/a
 
      04-10-2004
"Rudi Ahlers" <SP4M_Rudi@SP4M_Bonzai.org.za_SP4M> wrote in message
news:HvadnSvs0ZcIruXdRVn-...
> I have the following link: http://hobbit/newhp/index.asp?l=advert, and it
> doesn't do what I want it to do, even though the file exists.
> If a file doesn't exist, it should use home.asp as default, yet it uses
> home.asp as default regardless if the file exists or not?
> Here is the script:
>
>
> linkname = request.QueryString("l")


Probably you do **not** want your website to *expose* absolute path
information such as c:\mydata\file.txt

> if linkname <> "" then
> page = linkname & ".html"

go for
page = Server.MapPath(linkname + ".html")
where linkname must be a page in relative format like "scripts/mypage.asp"

> If objFSO.FileExists(page) = false Then
> page = "home.asp"
> End If



> end if
>
> If http://hobbit/newhp/index.asp?l=advert123 (which doesn't exist) it goes
> to home.asp, which is what I want, but it also does it for all the files
> that does exist, and reason for that?
>
> --
>
> Kind Regards
> Rudi Ahlers
> +27 (82) 926 1689
>
> Greater love has no one than this, that he lay down his life for his

friends
> (John 15:13).
>
>


 
Reply With Quote
 
Lord Merlin
Guest
Posts: n/a
 
      04-10-2004
That works rather well, but what are the security implications?
Can it cause any harm if it's not being displayed? And even if it is? What
good is it to anyone?

--

Kind Regards
Rudi Ahlers
+27 (82) 926 1689

Greater love has no one than this, that he lay down his life for his friends
(John 15:13).
"Egbert Nierop (MVP for IIS)" <> wrote in
message news:...
"Rudi Ahlers" <SP4M_Rudi@SP4M_Bonzai.org.za_SP4M> wrote in message
news:HvadnSvs0ZcIruXdRVn-...
> I have the following link: http://hobbit/newhp/index.asp?l=advert, and it
> doesn't do what I want it to do, even though the file exists.
> If a file doesn't exist, it should use home.asp as default, yet it uses
> home.asp as default regardless if the file exists or not?
> Here is the script:
>
>
> linkname = request.QueryString("l")


Probably you do **not** want your website to *expose* absolute path
information such as c:\mydata\file.txt

> if linkname <> "" then
> page = linkname & ".html"

go for
page = Server.MapPath(linkname + ".html")
where linkname must be a page in relative format like "scripts/mypage.asp"

> If objFSO.FileExists(page) = false Then
> page = "home.asp"
> End If



> end if
>
> If http://hobbit/newhp/index.asp?l=advert123 (which doesn't exist) it goes
> to home.asp, which is what I want, but it also does it for all the files
> that does exist, and reason for that?
>
> --
>
> Kind Regards
> Rudi Ahlers
> +27 (82) 926 1689
>
> Greater love has no one than this, that he lay down his life for his

friends
> (John 15:13).
>
>



 
Reply With Quote
 
Egbert Nierop \(MVP for IIS\)
Guest
Posts: n/a
 
      04-10-2004
"Lord Merlin" <SP4M_Rudi@SP4M_Bonzai.org.za_SP4M> wrote in message
news:...
> That works rather well, but what are the security implications?
> Can it cause any harm if it's not being displayed? And even if it is? What
> good is it to anyone?



No absolute paths should be passed to and from a webserver. I don't quite
understand your question but figure, a script, on a non completely tested or
configured site can exploit your \windows\system32 directory. Therefore, use
relative paths.

--
compatible web farm Session replacement for Asp and Asp.Net
http://www.nieropwebconsult.nl/asp_session_manager.htm

 
Reply With Quote
 
Roland Hall
Guest
Posts: n/a
 
      04-11-2004
"Rudi Ahlers" wrote in message news:HvadnSvs0ZcIruXdRVn-...
: I have the following link: http://hobbit/newhp/index.asp?l=advert, and it
: doesn't do what I want it to do, even though the file exists.
: If a file doesn't exist, it should use home.asp as default, yet it uses
: home.asp as default regardless if the file exists or not?
: Here is the script:
:
:
: linkname = request.QueryString("l")
:
: if linkname <> "" then
: page = linkname & ".html"
: If objFSO.FileExists(page) = false Then
: page = "home.asp"
: End If
: end if
:
: If http://hobbit/newhp/index.asp?l=advert123 (which doesn't exist) it goes
: to home.asp, which is what I want, but it also does it for all the files
: that does exist, and reason for that?

Your code reads as:

linkname=advert123
if linkname not empty then
page = advert.html
if advert.html not exist then
page = home.asp
end if
endif

That's why it always hits the home page when the tested file is not present
although the redirect is not shown here.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp


 
Reply With Quote
 
Lord Merlin
Guest
Posts: n/a
 
      04-11-2004
I don't quite understand what you mean.

See, I want to call a page. If no input is given, home.asp should be parsed.
If an input is given, it should be checked if the file exists, if it doesn't
parse home.asp again. If the file does exists, parse that file.
So my logic is right.......

linkname=advert123 - (i.e
http://localhost/index.asp?l=advert123)
if linkname not empty then - (i.e the variable linkname
contains something)
ipage = linkname & ".html" - make the page the contents of
linkname, which will be executed like this: server.execute(page)
if ipage not exist then - see if the filename being
called exists, if not
ipage = "home.asp" - use home.asp
end if
endif


You see, if server.execute is given a blank field to parse, it returns an
error. Thus I need to know if the file being called actually exists or not.
And to keep a list of say over 2000 pages long in a case statement is not
going to work. Rather check if the file being called exists, if it doesn't
use home.asp as default.

--

Kind Regards
Rudi Ahlers
+27 (82) 926 1689

Greater love has no one than this, that he lay down his life for his friends
(John 15:13).
"Roland Hall" <nobody@nowhere> wrote in message
news:...
"Rudi Ahlers" wrote in message news:HvadnSvs0ZcIruXdRVn-...
: I have the following link: http://hobbit/newhp/index.asp?l=advert, and it
: doesn't do what I want it to do, even though the file exists.
: If a file doesn't exist, it should use home.asp as default, yet it uses
: home.asp as default regardless if the file exists or not?
: Here is the script:
:
:
: linkname = request.QueryString("l")
:
: if linkname <> "" then
: page = linkname & ".html"
: If objFSO.FileExists(page) = false Then
: page = "home.asp"
: End If
: end if
:
: If http://hobbit/newhp/index.asp?l=advert123 (which doesn't exist) it goes
: to home.asp, which is what I want, but it also does it for all the files
: that does exist, and reason for that?

Your code reads as:

linkname=advert123
if linkname not empty then
page = advert.html
if advert.html not exist then
page = home.asp
end if
endif

That's why it always hits the home page when the tested file is not present
although the redirect is not shown here.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp



 
Reply With Quote
 
Bob Barrows
Guest
Posts: n/a
 
      04-11-2004
Use response.write to check the value of the page variable after the if
statement. You will see...

Lord Merlin wrote:
> I don't quite understand what you mean.
>
> See, I want to call a page. If no input is given, home.asp should be
> parsed. If an input is given, it should be checked if the file
> exists, if it doesn't parse home.asp again. If the file does exists,
> parse that file.
> So my logic is right.......
>
> linkname=advert123 - (i.e
> http://localhost/index.asp?l=advert123)
> if linkname not empty then - (i.e the variable linkname
> contains something)
> ipage = linkname & ".html" - make the page the contents
> of linkname, which will be executed like this: server.execute(page)
> if ipage not exist then - see if the filename
> being called exists, if not
> ipage = "home.asp" - use home.asp
> end if
> endif
>
>
> You see, if server.execute is given a blank field to parse, it
> returns an error. Thus I need to know if the file being called
> actually exists or not. And to keep a list of say over 2000 pages
> long in a case statement is not going to work. Rather check if the
> file being called exists, if it doesn't use home.asp as default.
>
> --
>
> Kind Regards
> Rudi Ahlers
> +27 (82) 926 1689
>
> Greater love has no one than this, that he lay down his life for his
> friends (John 15:13).
> "Roland Hall" <nobody@nowhere> wrote in message
> news:...
> "Rudi Ahlers" wrote in message news:HvadnSvs0ZcIruXdRVn-...
>> I have the following link: http://hobbit/newhp/index.asp?l=advert,
>> and it doesn't do what I want it to do, even though the file exists.
>> If a file doesn't exist, it should use home.asp as default, yet it
>> uses home.asp as default regardless if the file exists or not?
>> Here is the script:
>>
>>
>> linkname = request.QueryString("l")
>>
>> if linkname <> "" then
>> page = linkname & ".html"
>> If objFSO.FileExists(page) = false Then
>> page = "home.asp"
>> End If
>> end if
>>
>> If http://hobbit/newhp/index.asp?l=advert123 (which doesn't exist)
>> it goes to home.asp, which is what I want, but it also does it for
>> all the files that does exist, and reason for that?

>
> Your code reads as:
>
> linkname=advert123
> if linkname not empty then
> page = advert.html
> if advert.html not exist then
> page = home.asp
> end if
> endif
>
> That's why it always hits the home page when the tested file is not
> present although the redirect is not shown here.




--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
To be not, or not to be not? Ruby Freak Ruby 2 09-23-2008 08:04 AM
Why not 'foo = not f' instead of 'foo = (not f or 1) and 0'? Kristian Domke Python 11 01-23-2008 07:27 PM
'' is not a valid name. Make sure that it does not include invalid characters or punctuation and that it is not too long. rote ASP .Net 2 01-23-2008 03:07 PM
Cisco 3640 3620 3600 not detecting, not enabling, not working: NM-2FE2W Taki Soho Cisco 0 09-22-2004 07:28 AM
maintaining control with cookies (not strictly an ASP or even server side question. But not not either) Stephanie Stowe ASP General 2 04-07-2004 04:23 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57