Home All Groups Group Topic Archive Search About

How do I find out the page name in ASP

Author
15 Jul 2005 2:06 PM
Charts
I know it’s trivial but I need it quickly.  How do I find out the page name
in ASP, which I am currently using?   I did that before but I cannot
remember.  I remembered it’s in Server or Application object collection, but
could not find out.  Thanks for help.
Charts

Author
15 Jul 2005 3:00 PM
theath
I do it this way:

<code>
            Dim pn As String = Me.Page.ToString()
            pn = pn.Substring(4, pn.IndexOf("_aspx") - 4)
</code>
Author
15 Jul 2005 5:43 PM
Andrew Backer
What name do you want?  The page's class?  the actual *physical* page
that was called, the currently executing page (after a server.transfer,
etc), after a path remapping ?  :)

Since you mention server variables, I think the var is "script_name",
ie :

Request.ServerVariables["SCRIPT_NAME"]...

FYI, I would just turn on trace, ok, and at the bottom you will see the
entire serverVariables collection output.  Just check that for the
variable you need, then call it like above :)

- Andrew
Author
15 Jul 2005 7:55 PM
Charts
Andrew,
Request.ServerVariables["SCRIPT_NAME"] is exactly what I wanted.  Thanks so
much.  Charts

Show quoteHide quote
"Andrew Backer" wrote:

> What name do you want?  The page's class?  the actual *physical* page
> that was called, the currently executing page (after a server.transfer,
> etc), after a path remapping ?  :)
>
> Since you mention server variables, I think the var is "script_name",
> ie :
>
> Request.ServerVariables["SCRIPT_NAME"]...
>
> FYI, I would just turn on trace, ok, and at the bottom you will see the
> entire serverVariables collection output.  Just check that for the
> variable you need, then call it like above :)
>
> - Andrew
>
>