Translate virtual ~ path in app_code codebehind

Discussion in 'ASP .Net' started by Smokey Grindle, Jun 20, 2006.

  1. I need to take a virtual path say "~\Site\Default.aspx" and convert it into
    the correct site path in the app_code folder for codebehind. how do you go
    about doing it at this level? I found it very easy to do it on a user
    control and web page by using the system.web.ui.page.resolveurl function,
    but unsure how to do a similar fask at the code level in the app_code
    folder. Any ideas? thanks!
    Smokey Grindle, Jun 20, 2006
    #1
    1. Advertising

  2. Server.MapPath will do it for you.


    if (HttpContext.Current == null)
    {
    throw new Exception("Method must be called from a web context");
    }
    HttpServerUtility server = HttpContext.Current.Server;
    server.MapPath(address);

    --
    http://www.openmymind.net/
    http://www.fuelindustries.com/


    "Smokey Grindle" <> wrote in message
    news:%...
    >I need to take a virtual path say "~\Site\Default.aspx" and convert it into
    >the correct site path in the app_code folder for codebehind. how do you go
    >about doing it at this level? I found it very easy to do it on a user
    >control and web page by using the system.web.ui.page.resolveurl function,
    >but unsure how to do a similar fask at the code level in the app_code
    >folder. Any ideas? thanks!
    >
    Karl Seguin [MVP], Jun 20, 2006
    #2
    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. Replies:
    9
    Views:
    478
    Juan T. Llibre
    Dec 7, 2006
  2. =?Utf-8?B?SmVmZiBCZWVt?=

    physical path to virtual path under virtual directory

    =?Utf-8?B?SmVmZiBCZWVt?=, Aug 1, 2007, in forum: ASP .Net
    Replies:
    4
    Views:
    1,023
    Eliyahu Goldin
    Aug 1, 2007
  3. marss
    Replies:
    5
    Views:
    991
    marss
    Sep 13, 2007
  4. chandan
    Replies:
    2
    Views:
    599
    chandan
    Dec 14, 2007
  5. Scott Tilton

    Convert Physical path to Virtual path?

    Scott Tilton, Jul 11, 2003, in forum: ASP General
    Replies:
    2
    Views:
    601
    Dhananjay Modak
    Jul 11, 2003
Loading...

Share This Page