[Mono-bugs] [Bug 59608][Nor] New - basePageType and Virtual Hosts don't work
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Fri, 4 Jun 2004 13:14:56 -0400 (EDT)
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by andrewarnott@byu.edu.
http://bugzilla.ximian.com/show_bug.cgi?id=59608
--- shadow/59608 2004-06-04 13:14:56.000000000 -0400
+++ shadow/59608.tmp.30606 2004-06-04 13:14:56.000000000 -0400
@@ -0,0 +1,172 @@
+Bug#: 59608
+Product: Mono: Class Libraries
+Version: unspecified
+OS: SUSE 9.0
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: Sys.Web
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: AndrewArnott@byu.edu
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: basePageType and Virtual Hosts don't work
+
+Background:
+The <pages pageBaseType="..."/> tag in Web.config can override the default
+base class an ASPX page. The default base class is System.Web.UI.Page. To
+override default behavior for all pages on a site, one can write another
+Page class that inherits from System.Web.UI.Page. Then use this <pages>
+tag to make your own class the default base class for all pages. The
+assembly containing your new base class is included in the bin directory
+for the web site.
+
+Description of Problem:
+This behavior works correctly when only one web site is being hosted. But
+when two virtual hosts are configured in Apache, only the first web site to
+be displayed works. That is, the first web site will be displayed using
+the new base class, which means Mono found the assembly in the bin folder
+that contains that class. The second web site (second in browser viewing
+order after a mod-mono-server.exe restart) fails to display any page,
+giving an error indicating that Mono could not find the base class.
+
+Steps to reproduce the problem:
+0. In this example, biscuit.byu.edu is the host name of the linux server,
+testmfhd.byu.edu and testgerontology.byu.edu are aliases, and are
+configured as the virtual hosts.
+
+1. Configure httpd.conf with these lines:
+LoadModule mono_module modules/libmod_mono.so
+MonoUnixSocket /tmp/mod_mono_server
+NameVirtualHost *:80
+<VirtualHost *:80>
+ DocumentRoot "/usr/local/apache/htdocs"
+ ServerName biscuit.byu.edu
+</VirtualHost>
+
+<VirtualHost *:80>
+ DocumentRoot "/home/andrew/localweb/mfhd"
+ ServerName testmfhd.byu.edu
+ <Location />
+ SetHandler mono
+ </Location>
+</VirtualHost>
+
+<VirtualHost *:80>
+ DocumentRoot "/home/andrew/localweb/gerontology"
+ ServerName testgerontology.byu.edu
+ <Location />
+ SetHandler mono
+ </Location>
+</VirtualHost>
+
+MonoApplicationsConfigFile "/usr/local/apache/conf/webapps/config.xml"
+
+2. Create the /usr/local/apache/conf/webapps/config.xml file:
+<apps>
+
+<web-application>
+ <name>testmfhd.byu.edu</name>
+ <vhost>testmfhd.byu.edu</vhost>
+ <vpath>/</vpath>
+ <path>/home/andrew/localweb/mfhd</path>
+</web-application>
+
+<web-application>
+ <name>testgerontology.byu.edu</name>
+ <vhost>testgerontology.byu.edu</vhost>
+ <vpath>/</vpath>
+ <path>/home/andrew/localweb/gerontology</path>
+</web-application>
+
+</apps>
+
+3. Write and compile an assembly that merely has a class that inherits from
+System.Web.UI.Page, and modify the Render method to add some unique
+signature to the page output, so that you can accurately determine which
+page class is being used later.
+
+4. Create the two web sites. They can be quite empty. If you start with a
+standard Visual Studio .NET created web application, modify the web.config
+file to include a line similar to:
+<pages pageBaseType="School.Theme.Page, SchoolCtrls"/>
+Where School.Theme.Page is the new base class, and SchoolCtrls is the
+assembly name, not including the .dll extension.
+Make this modification for each web.config file in your two sites. I am
+currently using a strong-named assembly, so my tag looks like the
+following, but the behavior for me was the same whether I tried a
+strong-named or a non-strong-named assembly:
+<pages pageBaseType="School.Theme.Page, SchoolCtrls,
+Version=1.0.1612.19143, Culture=neutral, PublicKeyToken=80cec71687825c4c"/>
+
+5. Remove all code-behind files and ensure that no base page class is
+specified at the top of the .aspx files. You might test these two sites in
+IIS to see that they would display properly with the new page base class
+just to make sure you have the web sites set up right.
+
+6. Start mod-mono-server.exe like this:
+mono /usr/bin/mod-mono-server.exe --appconfigfile
+/usr/local/apache/conf/webapps/config.xml
+
+7. With mod-mono-server.exe running, use the command:
+chmod 777 /tmp/mod_mono_server
+
+8. Now start/restart Apache 2.0.x
+
+9. Browse to either site. It should appear with the correct base page
+class. Now browser to the other site. It will give an error. Restarting
+mod-mono-server.exe and browsing the sites in reverse order will reverse
+which site works and which fails. The error is included below.
+
+Actual Results:
+
+Server Error in '/' Application
+Parser Error
+Description: Error parsing a resource required to service this request.
+Review your source file and modify it to fix this error.
+
+Error message: Cannot find type School.Theme.Page, SchoolCtrls,
+Version=1.0.1612.19143, Culture=neutral, PublicKeyToken=80cec71687825c4c
+
+File name: /home/andrew/localweb/gerontology/default.aspx Line: 1
+
+Source Error:
+
+<%@ Page language="c#" AutoEventWireup="false" %>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
+<HTML>
+ <HEAD>
+
+
+Expected Results:
+
+The second site to display correctly with the custom base page class!
+
+
+How often does this happen?
+Every time.
+
+Additional Information:
+There is a workaround that hides the problem temporarily:
+1. Rename both web.config files to hide them from mod-mono-server. This
+effectively disables the templates.
+2. Verify that both sites now appear properly, except that they use
+System.Web.UI.Page instead of your custom base class.
+3. Modify each default.aspx file to contain code that simply reaches in and
+creates an object of your base page class, similar to:
+<%
+School.Theme.Page pg = new School.Theme.Page();
+Response.Write("Object created!");
+%>
+4. (Re)start mod-mono-server.
+5. chmod 777 /tmp/mod_mono_server
+6. Browse to each site, and check that "Object created!" shows up without
+an error.
+7. Rename the web.config files so that they show up to mod-mono-server, and
+remove the inline code added to the default.aspx files.
+8. Browse to each web site again. This time the base page class will work
+for both web sites!