Get aspx File Name

J

Jeff

I need to determine, at runtime, the page name of the currently requested
aspx page.
Page.ToString(), returns sumething like "ASP.MyFile_aspx". What I'd prefer
is to get the actual file name "MyFile.aspx".

Any suggestions?

Thanks.
 
R

Rob Meade

...
I need to determine, at runtime, the page name of the currently requested
aspx page.
Page.ToString(), returns sumething like "ASP.MyFile_aspx". What I'd prefer
is to get the actual file name "MyFile.aspx".

In vanilla ASP you could have used, Request.ServerVariables("SCRIPT_NAME") -
but I'm sure someone here will have a better way to resolve it in .net :eek:)

Regards

Rob
 
R

Ramdas

why not use page.Request.Path
-----Original Message-----
I need to determine, at runtime, the page name of the currently requested
aspx page.
Page.ToString(), returns sumething
like "ASP.MyFile_aspx". What I'd prefer
 
A

Andrea Williams

Here's what I've been using:

public static string PageName()

{

string strTemp;

int intPos;

strTemp =
System.Web.HttpContext.Current.Request.ServerVariables["SCRIPT_NAME"].ToStri
ng();

intPos = strTemp.LastIndexOf("/");

strTemp = strTemp.Substring(intPos + 1);

return strTemp;

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top