homepage Welcome to WebmasterWorld Guest from 54.166.148.189
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
Forum Library, Charter, Moderators: ocean10000

Microsoft IIS Web Server and ASP.NET Forum

    
How do I get the file name?
Ertai




msg:957480
 2:56 am on Feb 9, 2004 (gmt 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...

 

ebouwsema




msg:957481
 4:13 pm on Feb 9, 2004 (gmt 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

txbakers




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

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

Ninkasi




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

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




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

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved