Welcome to WebmasterWorld Guest from 54.161.118.57

Forum Moderators: ocean10000

Message Too Old, No Replies

How do I get the file name?

     
2:56 am on Feb 9, 2004 (gmt 0)

New User

10+ Year Member

joined:Nov 18, 2003
posts:12
votes: 0


It's probably the simplist thing, and I'm having so much trouble doing it.

I'm trying to compare a name of a page from a Database, to that of the current page.

But I don't know how to retrieve the name of the current page.

Example:

IF DBPageName.aspx = CurrentPageName.aspx THEN
do something
END IF

but CurrentPage.aspx needs to be retrieved from the Q-string somehow.

help...

4:13 pm on Feb 9, 2004 (gmt 0)

New User

10+ Year Member

joined:Feb 3, 2004
posts:14
votes: 0


Try this:

Dim strPath As String = Request.ServerVariables("PATH_INFO")
strPath = strPath.Substring(strPath.LastIndexOf("/") + 1)

It calls the "PATH_INFO" server variable and separates only the page name out based on the last instance of "/".

Hope this helps,
Eric

4:14 pm on Feb 9, 2004 (gmt 0)

Senior Member

WebmasterWorld Senior Member txbakers is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Sept 1, 2001
posts:4392
votes: 0


There's also the SCRIPT_NAME server variable which returns the file name part of the URL.

Ninkasi

5:48 am on Feb 18, 2004 (gmt 0)

Inactive Member
Account Expired

 
 


Hey,

I was looking for exactly the same thing! Thank-you VERY much for pointing that out! I have been looking for like at least 5 hours for that small piece of code!

.::// Ninkasi \\::.

Xoc

8:58 pm on Feb 18, 2004 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Jan 18, 2001
posts:1437
votes: 0


You might want to check this thread, [webmasterworld.com ], that shows all the different options for Request.ServerVariables.