Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. HttpContext.Current.Server.MapPath

HttpContext.Current.Server.MapPath

Scheduled Pinned Locked Moved ASP.NET
helpcsharpvisual-studiosysadmindebugging
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    KishoreT
    wrote on last edited by
    #1

    I have an xml configuration file in my project. when I am working in debug mode of .net IDE it is working fine, but when i tried to launch the project from IE, it is taking different path ex: below code works well in debug mode, but unable to launch in IE directly (http://localhost/WebProj/login.aspx) Pathtype A:

    HttpContext.Current.Server.MapPath(@"\Configuration\xyz.xml");

    below code works well in IE and debug mode but having different problem. Pathtype B:

    HttpContext.Current.Server.MapPath("") + @"\Configuration\xyz.xml";

    Problem: I have a folder MainPages under root folder of the project. under this I have AdminPages. These admin pages are not retrieving if I used pathtype B specified above and gives error no page available, but works fine when pathtype A specified above is used which runs in debug mode only but not able launch from IE. Help me please.

    J K 2 Replies Last reply
    0
    • K KishoreT

      I have an xml configuration file in my project. when I am working in debug mode of .net IDE it is working fine, but when i tried to launch the project from IE, it is taking different path ex: below code works well in debug mode, but unable to launch in IE directly (http://localhost/WebProj/login.aspx) Pathtype A:

      HttpContext.Current.Server.MapPath(@"\Configuration\xyz.xml");

      below code works well in IE and debug mode but having different problem. Pathtype B:

      HttpContext.Current.Server.MapPath("") + @"\Configuration\xyz.xml";

      Problem: I have a folder MainPages under root folder of the project. under this I have AdminPages. These admin pages are not retrieving if I used pathtype B specified above and gives error no page available, but works fine when pathtype A specified above is used which runs in debug mode only but not able launch from IE. Help me please.

      J Offline
      J Offline
      Jens Meyer
      wrote on last edited by
      #2

      Hi KishoreT, if i understand you right, you have the xml-file in a subdirectory of the root of the webpage. The subdirctory is "Configuration". Therefore i suggest you use the following to get the path:

      HttpContext.Current.Server.MapPath(@"~\Configuration\xyz.xml");

      The difference is the ~ (tilde) character. It represents the homedirectory or root of the webapp. Hope this helps Regards Jens

      When in trouble, when in doubt, run in circles, scream and shout

      1 Reply Last reply
      0
      • K KishoreT

        I have an xml configuration file in my project. when I am working in debug mode of .net IDE it is working fine, but when i tried to launch the project from IE, it is taking different path ex: below code works well in debug mode, but unable to launch in IE directly (http://localhost/WebProj/login.aspx) Pathtype A:

        HttpContext.Current.Server.MapPath(@"\Configuration\xyz.xml");

        below code works well in IE and debug mode but having different problem. Pathtype B:

        HttpContext.Current.Server.MapPath("") + @"\Configuration\xyz.xml";

        Problem: I have a folder MainPages under root folder of the project. under this I have AdminPages. These admin pages are not retrieving if I used pathtype B specified above and gives error no page available, but works fine when pathtype A specified above is used which runs in debug mode only but not able launch from IE. Help me please.

        K Offline
        K Offline
        KishoreT
        wrote on last edited by
        #3

        Hey thank u its working by placing ~.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups