Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / December 2007

Tip: Looking for answers? Try searching our database.

MapPath returning wrong string

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
GaryDean - 03 Dec 2007 16:44 GMT
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\\AnonymousAccess\\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
Milosz Skalecki [MCAD] - 03 Dec 2007 23:28 GMT
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
Signature

Milosz

> The following command...
> string DebugString =
[quoted text clipped - 20 lines]
> Thanks
> Gary
Steven Cheng[MSFT] - 04 Dec 2007 07:13 GMT
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==?=
<mily242@DONTLIKESPAMwp.pl>
>References:  <#gqo5ucNIHA.1168@TK2MSFTNGP02.phx.gbl>
>Subject: RE: MapPath returning wrong string
>Date: Mon, 3 Dec 2007 15:28:03 -0800

>Hi Gary,
>
[quoted text clipped - 29 lines]
>> Thanks
>> Gary

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.