how to determine the physical path of a page

Discussion in 'ASP .Net' started by Vaclav Jedlicka, Aug 18, 2006.

  1. Hello,

    I created a web app using Visual Web Developer 2005 Express Edition. The
    project is called "mytest".

    When I view a page in the browser, its URL looks like

    http://localhost:3415/myTest/SomePage.aspx

    I need top determine the physical path of the page. I call

    string ls_path = HttpContext.Current.Server.MapPath("/SomePage.aspx);

    I get an error, because the "myTest" part is missing there. When I call

    string ls_path = HttpContext.Current.Server.MapPath("/myTest/SomePage.aspx);

    It works ok, but i do not want to do that, because on the production server
    there will be no "myTest".

    It will be something like

    http://some_domain/SomePage.aspx

    What can I do?


    Thank you
    Vaclav
     
    Vaclav Jedlicka, Aug 18, 2006
    #1
    1. Advertising

  2. Vaclav Jedlicka

    Siva M Guest

    Did you try Request.PhysicalPath?

    "Vaclav Jedlicka" <> wrote in message
    news:...
    Hello,

    I created a web app using Visual Web Developer 2005 Express Edition. The
    project is called "mytest".

    When I view a page in the browser, its URL looks like

    http://localhost:3415/myTest/SomePage.aspx

    I need top determine the physical path of the page. I call

    string ls_path = HttpContext.Current.Server.MapPath("/SomePage.aspx);

    I get an error, because the "myTest" part is missing there. When I call

    string ls_path = HttpContext.Current.Server.MapPath("/myTest/SomePage.aspx);

    It works ok, but i do not want to do that, because on the production server
    there will be no "myTest".

    It will be something like

    http://some_domain/SomePage.aspx

    What can I do?


    Thank you
    Vaclav
     
    Siva M, Aug 18, 2006
    #2
    1. Advertising

  3. Hello, thank you for your help!

    I do not need to know the path of the current request. Tha was just an
    example.

    in fact, I need to know the path of a Luecene folder when Lucene full text
    indices are stored. So the real code is:

    string ls_path = HttpContext.Current.Server.MapPath("/Lucene");
     
    Vaclav Jedlicka, Aug 18, 2006
    #3
  4. Request.PhysicalPath will give you what you want.

    See a sample running at : http://asp.net.do/test/pathinfo.aspx



    Juan T. Llibre, asp.net MVP
    aspnetfaq.com : http://www.aspnetfaq.com/
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en español : http://asp.net.do/foros/
    ===================================
    "Vaclav Jedlicka" <> wrote in message news:...
    > Hello,
    >
    > I created a web app using Visual Web Developer 2005 Express Edition. The project is called
    > "mytest".
    >
    > When I view a page in the browser, its URL looks like
    >
    > http://localhost:3415/myTest/SomePage.aspx
    >
    > I need top determine the physical path of the page. I call
    >
    > string ls_path = HttpContext.Current.Server.MapPath("/SomePage.aspx);
    >
    > I get an error, because the "myTest" part is missing there. When I call
    >
    > string ls_path = HttpContext.Current.Server.MapPath("/myTest/SomePage.aspx);
    >
    > It works ok, but i do not want to do that, because on the production server there will be no
    > "myTest".
    >
    > It will be something like
    >
    > http://some_domain/SomePage.aspx
    >
    > What can I do?
    >
    >
    > Thank you
    > Vaclav
    >
    >
     
    Juan T. Llibre, Aug 18, 2006
    #4
  5. You'll need to phrase your questions more precisely, Vaclav.

    If you need to know the path of a folder, please say so.

    Asking for the physical path of the page when what you
    want is the path of a folder is confusing...and time-wasting.




    Juan T. Llibre, asp.net MVP
    aspnetfaq.com : http://www.aspnetfaq.com/
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en español : http://asp.net.do/foros/
    ===================================
    "Vaclav Jedlicka" <> wrote in message
    news:...
    > Hello, thank you for your help!
    >
    > I do not need to know the path of the current request. Tha was just an example.
    >
    > in fact, I need to know the path of a Luecene folder when Lucene full text indices are stored. So
    > the real code is:
    >
    > string ls_path = HttpContext.Current.Server.MapPath("/Lucene");
     
    Juan T. Llibre, Aug 18, 2006
    #5
    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. Igor
    Replies:
    1
    Views:
    479
  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,049
    Eliyahu Goldin
    Aug 1, 2007
  3. marss
    Replies:
    5
    Views:
    1,005
    marss
    Sep 13, 2007
  4. Scott Tilton

    Convert Physical path to Virtual path?

    Scott Tilton, Jul 11, 2003, in forum: ASP General
    Replies:
    2
    Views:
    612
    Dhananjay Modak
    Jul 11, 2003
  5. Replies:
    1
    Views:
    125
    Kyle Peterson
    Apr 22, 2006
Loading...

Share This Page