HttpContext.Current.Server.MapPath
-
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.
-
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.
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
-
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.