Georged Weblog

Have you georged your mind?

$25 ASP.NET challenge

I'm yet to see ASP.NET code which does not use '~' mapping feature in Server.MapPath. We all love this feature, except... wait a minute... it is not documented?! Search on MSDN failed to uncover any statement stating that '~' in MapPath function refers to a virtual root (the task was not made any easier by the fact that tilde is ignored in a search). Could it be that we're all typing megalines of code against undocumented feature? And what, apart from bazillions of angered developers around the world, will stop ASP.NET team from changing it in 2.0 from '~' to, say '$', 'œ', '¥' or '½', for this matter :-). 

Now, here is the georged challenge: the first person who points me to a piece of documentation explaining usage of a tilde character in MapPath is entitled to AUS $25 (about US$17 and rising). Money will be transferred to a PayPal account or similar.

Rules:

  1. It must be official documentation, i.e. references to samples, user groups, magazine articles, blogs, etc will not be considered.
  2. 'First' will be judged by UTC time of the reply/post/email.
  3. I decide who's first and whether pointer/answer is correct.
  4. if(you.disagree) goto 3;
  5. Ah, what the heck, Microsoft employees are also eligible to enter :-)
Anyone?
 
Cheers
Georged

Comments

Darshan Singh said:

I'll send more links, but here is one you can look at:

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&newwindow=1&frame=right&th=405eeb04f57bac86&seekm=009c01c2d2e5%24f6c31900%248bf82ecf%40TK2MSFTNGXA05#link4

OR (http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&newwindow=1&threadm=009c01c2d2e5%24f6c31900%248bf82ecf%40TK2MSFTNGXA05&rnum=1&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26newwindow%3D1%26q%3DServer%2BMapPath%2Btilde)


Also see: http://www.aspalliance.com/remas/ASP.NET/GreatFeatures/Tilde/


Best wishes,
Darshan Singh
Creator of RSSConnect: http://www.PerfectXML.com/RSSConnect
# July 2, 2003 10:31 AM

George Doubinski said:

Thanks, Dashan - you're first to reply. Unfortunately, answer does not cut it. Neither groups nor books are official documentation. Otherwise, there would be no books like 'Undocumented Windows NT' :-)

# July 2, 2003 10:39 AM

Randy Ridge said:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconincludingpageletcontrolinanotherwebformspage.asp

While not specifically in relation to MapPath, this does indeed mention the usage of tilde in relation to paths.

If you deem this acceptable, you can keep your $17 US :)
# July 2, 2003 10:45 AM

Darshan Singh said:

Yes, you are right. The feature is not "officially" documented (yet).

As mentioned by the Microsoft ASP.NET team member in the google link that I sent, this feature is only mentioend in the Microsoft Press book. I checked 1.1 documentation, it is not mentioned there. Neigher I could find it in any of the KB articles (including latest KB articles)

ASP.NET Web site has some disussion on this topic, if you are interested to review them (http://asp.net/Forums/Search/default.aspx?tabindex=1&searchText=tilde).

Darshan Singh
# July 2, 2003 10:52 AM

Randy Ridge said:

Also you'll note that UrlPath contains a method called bool IsAppRelativePath(string), using Reflector one sees that it checks the supplied path to see if tilde (char 126) is the first character, being lazy I didn't check to see where this method might be called indirectly by MapPath..
# July 2, 2003 10:57 AM

Randy Ridge said:

Ahh.. here you go:

text2 = HttpRuntime.AppDomainAppVirtualPath;
if ((relative.Length == 1) && (relative.Chars[0] == 126))
{
return text2;
}

From UrlPath.Combine which is indeed called if you trace through MapPath. 126 = ~.

Gotta love Reflector :)
# July 2, 2003 11:02 AM

George Doubinski said:

Hey, you're one step ahead of me! Just found the same, went to reply to your first comment only to find that you're already there :-). Call Tree in Reflector is sweet (if only I could say: here is X and here is Y - give me all possible calling paths from X yo Y. May be, I should write in add-in for that :-)
# July 2, 2003 11:19 AM

Luke Tymowski said:

Here's an article on MSDN that describes using the tilde:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconregister.asp

# July 2, 2003 3:16 PM

James Avery said:

This "feature" is more like a bug, because it is not really how this method is designed to be used. The bug was going to be fixed in 1.1, but they decided that it would break way too much code since everyone was already using it in the the wrong way. This is why I doubt you will find any documentation on this "feature".

-James
# July 2, 2003 4:41 PM

on Ms site, does that qualify said:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconregister.asp
# July 2, 2003 8:56 PM

Denny said:

Hey don't know if anyone cares but....

it's UNIX / Linux shorthand for "Home"

like

$ CD ~
$ PWD /Home/Denny

thats where they got it from....
# October 16, 2003 6:17 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)