473,407 Members | 2,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

MapPath returning wrong string

The following command...
string DebugString =
System.Web.HttpContext.Current.Server.MapPath("App _Themes");
is executed from my ThemeManager.cs class in my App_code directory

It returns...
"c:\\inetpub\\wwwroot\\TaxBusiness\\AnonymousAcces s\\App_Themes"

The folders in my website project are...
Admin
AnonymousAccess
App_Code
App_Data
App_Themes
Bin.. etc

MapPath should have returned...
"c:\\inetpub\\wwwroot\\TaxBusiness\\App_Themes "

Why did it stick the extra \\AnonymousAccess directory in there?
App_Themes is a direct child of the TaxBusiness website directory

Thanks
Gary
Dec 3 '07 #1
2 2744
Hi Gary,

Is there a possibility ThemeManager.cs class was used from a page/user
control inside the AnonymousAccess directory? You should have used :
string DebugString =
System.Web.HttpContext.Current.Server.MapPath("~/App_Themes");

Hope it helps
--
Milosz
"GaryDean" wrote:
The following command...
string DebugString =
System.Web.HttpContext.Current.Server.MapPath("App _Themes");
is executed from my ThemeManager.cs class in my App_code directory

It returns...
"c:\\inetpub\\wwwroot\\TaxBusiness\\AnonymousAcces s\\App_Themes"

The folders in my website project are...
Admin
AnonymousAccess
App_Code
App_Data
App_Themes
Bin.. etc

MapPath should have returned...
"c:\\inetpub\\wwwroot\\TaxBusiness\\App_Themes "

Why did it stick the extra \\AnonymousAccess directory in there?
App_Themes is a direct child of the TaxBusiness website directory

Thanks
Gary
Dec 3 '07 #2
Thanks for Milosz's input.

Hi Gary,

I agree with Milosz that you're recommended to utilize the "~" symbol of
ASP.NET, Server.MapPath("~/subdir") can give you any subdir's physical path
from your application's root directory. Relative path is not quite safe
here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: =?Utf-8?B?TWlsb3N6IFNrYWxlY2tpIFtNQ0FEXQ==?=
<mi*****@DONTLIKESPAMwp.pl>
>References: <#g**************@TK2MSFTNGP02.phx.gbl>
Subject: RE: MapPath returning wrong string
Date: Mon, 3 Dec 2007 15:28:03 -0800
>
Hi Gary,

Is there a possibility ThemeManager.cs class was used from a page/user
control inside the AnonymousAccess directory? You should have used :
string DebugString =
System.Web.HttpContext.Current.Server.MapPath(" ~/App_Themes");

Hope it helps
--
Milosz
"GaryDean" wrote:
>The following command...
string DebugString =
System.Web.HttpContext.Current.Server.MapPath("Ap p_Themes");
is executed from my ThemeManager.cs class in my App_code directory

It returns...
"c:\\inetpub\\wwwroot\\TaxBusiness\\AnonymousAcce ss\\App_Themes"

The folders in my website project are...
Admin
AnonymousAccess
App_Code
App_Data
App_Themes
Bin.. etc

MapPath should have returned...
"c:\\inetpub\\wwwroot\\TaxBusiness\\App_Themes "

Why did it stick the extra \\AnonymousAccess directory in there?
App_Themes is a direct child of the TaxBusiness website directory

Thanks
Gary
Dec 4 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: John Rebbeck | last post by:
I've got the directory f:\Company\Product set as web shared so it's got a virtual directory in the default web site on my test server's IIS. If I try to use Server.MapPath in that site it returns a...
3
by: Jon | last post by:
I'm calling Server.MapPath from global.asa through this line of code: Application("reports_dir") = Server.MapPath("Reports") The web application opens on a testing web server (not mine) at this...
6
by: JR | last post by:
My IIS Web site has a virtual directory called content mapped to a network share. If the home directory of the Web site is c:\inetpub\wwwroot and the virtual directory maps to the network share...
6
by: Nathan Sokalski | last post by:
When using the Server.MapPath() method, the results being returned are given as locations on my hard drive. I would like to be returned a result that is a URL, in my case something like the...
14
by: Lorenzo | last post by:
Hello, I have a web application with a virtual directory in it. With 'virtual directory' i mean a folder whose physical path is different from the physical path of the application, but in which...
3
by: rn5a | last post by:
Server.MapPath returns the physical file path that corresponds to the specified virtual path whereas Request.MapPath maps the specified virtual path to a physical path. Assuming that a file named...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.