[Mono-bugs] [Bug 575600] New: MapPath() does not work for virtual directories outside of the current application

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Sun Jan 31 08:34:42 EST 2010


http://bugzilla.novell.com/show_bug.cgi?id=575600

http://bugzilla.novell.com/show_bug.cgi?id=575600#c0


           Summary: MapPath() does not work for virtual directories
                    outside of the current application
    Classification: Mono
           Product: Mono: Class Libraries
           Version: 2.6.x
          Platform: 32bit
        OS/Version: openSUSE 11.2
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: System
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: test051102 at hotmail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


Created an attachment (id=339844)
 --> (http://bugzilla.novell.com/attachment.cgi?id=339844)
VS2008 Testprojects

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.1.7)
Gecko/20091221 Firefox/3.5.7 (.NET CLR 3.5.30729)

MapPath() does not work for virtual directories outside of the current
application. However, this works perfectly using WinXP and the integrated IIS.

Reproducible: Always

Steps to Reproduce:
To reproduce this bug I created two simple WebApplications using VS2008.
/WebApplication1 tries to access /WebApplication2 and read back some
application settings. To do this drag a Label from the toolbox to
WebApplication1 and add the following to the code behind class for
WebApplication1:

protected void Page_Load(object sender, EventArgs e)
        protected void Page_Load(object sender, EventArgs e)
{
    Label1.Text="Server.MapPath(\"/WebApplication1\"): ";

    try
    {
        Label1.Text += "<b>" + Server.MapPath("/WebApplication1") + "</b>";
    }
    catch
    {
        Label1.Text+="ERROR";
    }

    Label1.Text+="<br/>HostingEnvironment.MapPath(\"/WebApplication1\"): ";

    try
    {
        Label1.Text += "<b>" + HostingEnvironment.MapPath("/WebApplication1") +
"</b>";
    }
    catch
    {
        Label1.Text+="ERROR";
    }


    Label1.Text += "<br/>Server.MapPath(\"/WebApplication2\"): ";

    try
    {
        Label1.Text += "<b>" + Server.MapPath("/WebApplication2") + "</b>";
    }
    catch
    {
        Label1.Text += "ERROR";
    }

    Label1.Text += "<br/>HostingEnvironment.MapPath(\"/WebApplication2\"): ";

    try
    {
        Label1.Text += "<b>" + HostingEnvironment.MapPath("/WebApplication2") +
"</b>";
    }
    catch
    {
        Label1.Text += "ERROR";
    }

    string strPhysPath = Server.MapPath("/WebApplication2");
    Configuration config =
WebConfigurationManager.OpenWebConfiguration("/WebApplication2");

    KeyValueConfigurationElement test =
(KeyValueConfigurationElement)config.AppSettings.Settings["test"];

    if (test != null) Label1.Text += "<br/>[test]=" + test.Value.ToString();
        else Label1.Text += "<br/>[test]=null";
}

In the Web.config for WebApplication2 add
<appSettings>
      <add key="test" value="Hello World!"/>
</appSettings>


To deploy the applications on IIS do the following:
1.    Delete all files within c:\inetpub\wwwroot and copy the output of both
WebApplications from above to some other directory
2.    Create two virtual directories in IIS for each WebApplication and call
them WebApplication1 and WebApplication2 and map them to the directories from
(3)
3.    Start a browser and enter http://localhost/WebApplication1

To deploy the applications on the Mono 2.6.1 Live CD do the following:
1.    Create a directory below your home dir and copy both WebApplications to
it
2.    Enter xsp2 –applications
/WebApplication1:./WebApplication1,/WebApplication2:,/WebApplication2
3.    Start a browser and enter http://localhost/WebApplication1

Actual Results:  
The output from the test under Mono 2.6.1 is as follows:
“Server.MapPath("/WebApplication1"): /home/rupert/DemoTest/WebApplication1 
HostingEnvironment.MapPath("/WebApplication1"):
/home/rupert/DemoTest/WebApplication1
Server.MapPath("/WebApplication2"):
/home/rupert/DemoTest/WebApplication1/WebApplication2
HostingEnvironment.MapPath("/WebApplication2"):
/home/rupert/DemoTest/WebApplication1/WebApplication2
[test]=null“


Expected Results:  
The output from the test under IIS produces the following:

Server.MapPath("/WebApplication1"): C:\Inetpub\temp\WebApplication1
HostingEnvironment.MapPath("/WebApplication1"): C:\Inetpub\temp\WebApplication1
Server.MapPath("/WebApplication2"): C:\Inetpub\temp\WebApplication2
HostingEnvironment.MapPath("/WebApplication2"): C:\Inetpub\temp\WebApplication2
[test]=Hello World!


By the way, calling
WebConfigrationManager.OpenWebConfiguration(“/WebApplication2”) from within
WebApplication1 will throw an exception on Mono 2.6.1 but not on Windows/IIS.

All in all, the following methods are not working as expected
System.Web.HttpServerUtility.MapPath()
System.Web.Hosting.HostingEnvironment.MapPath()
System.Web.Configuration.WebConfigrationManager.OpenWebConfiguration()

-- 
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list