BUG: WinCE ASP Server.MapPath Method Behaves Differently than IIS Server.MapPath (290292)



The information in this article applies to:

  • Microsoft Windows CE Operating System, Versions 3.0

This article was previously published under Q290292

SYMPTOMS

The Server.MapPath method in an Active Server Pages (ASP) page executed under the Web server on Windows CE returns a different path than when the same ASP code is executed in an ASP page under Internet Information Server (IIS). Specifically, if the argument passed to MapPath does not begin with "/", ASP returns a path that is relative to the virtual root folder, not the current virtual path of where this ASP page is located. This may be a problem when you are adapting ASP pages designed for IIS to work on Windows CE.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

The Server.MapPath method is available to scripts running in ASP pages. It is used to translate a virtual path into its corresponding physical path in the Web server virtual root table.

Steps to Reproduce Behavior

Create a virtual folder named "/Test" on Windows CE and map it to "\Testdir". To do this, add the following entry to the SERVERS.REG file:

[HKEY_LOCAL_MACHINE\COMM\HTTPD\VROOTS\/Test]
(default)="\testdir"

; root directory, included in image by default configurations
[HKEY_LOCAL_MACHINE\COMM\HTTPD\VROOTS\/]
(default)="\window\www\wwwpub"
					

Use the following ASP code to create \Testdir\Test.asp, and then access http://<your CED device>/Test/Test.asp in a Web browser.
<%= Server.MapPath("mypage.htm") %>;
				

The returned text will read "\windows\www\wwwpub\mypage.htm" because Test.htm was assumed to be in the "/" virtual folder. IIS, under similar virtual root configuration, would return the string "\testdir\mypage.htm" because Test.asp is in the "/Test" virtual root.

To work around this behavior, the entire virtual root must be included in the Server.MapPath string. To get the virtual root of "/Test" in this example, the following ASP script would be required:
<%= Server.MapPath("/Test/mypage.htm") %>
				

Modification Type:MinorLast Reviewed:12/26/2003
Keywords:kbbug kbpending KB290292