Get aspx File Name

Discussion in 'ASP .Net' started by Jeff, Apr 26, 2004.

  1. Jeff

    Jeff Guest

    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.
     
    Jeff, Apr 26, 2004
    #1
    1. Advertising

  2. Jeff

    Rob Meade Guest

    "Jeff" wrote ...

    > 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
     
    Rob Meade, Apr 26, 2004
    #2
    1. Advertising

  3. Jeff

    Ramdas Guest

    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
    >is to get the actual file name "MyFile.aspx".
    >
    >Any suggestions?
    >
    >Thanks.
    >
    >
    >.
    >
     
    Ramdas, Apr 26, 2004
    #3
  4. 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;

    }

    "Jeff" <> wrote in message
    news:%...
    > 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.
    >
    >
     
    Andrea Williams, Apr 26, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sacha Korell

    Get file name of associated aspx file

    Sacha Korell, Jan 6, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    456
    Jeff Siver
    Jan 7, 2004
  2. John M
    Replies:
    1
    Views:
    1,233
    Kumar Reddi
    May 29, 2005
  3. ding feng
    Replies:
    2
    Views:
    2,848
    ding feng
    Jun 25, 2003
  4. Dave
    Replies:
    7
    Views:
    524
  5. Mike Schilling
    Replies:
    2
    Views:
    582
    Arne Vajhøj
    Mar 5, 2010
Loading...

Share This Page