[Mono-list] Web Forms and the @ Page directive

Gregory Junker gregory.junker@shockwaveaudio.com
Thu, 15 Apr 2004 18:31:48 -0400


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

At that link they say:

"In Web Forms that use code-behind files, the @ Page directive (or @
Control in user control files) contains attributes that specify the
relationship of the .aspx file and its code-behind file. These attribute
are:

      * Codebehind   In Visual Studio, this attribute references the
        name of a file that contains the class for the page. For
        example, if you create a Web Forms page in Visual Studio called
        WebForm1, the Codebehind attribute will point to WebForm1.aspx.
        vb or WebForm1.aspx.cs. This attribute is used only by the
        Visual Studio Web Forms Designer. It tells the designer where to
        find the page class so that the designer can create an instance
        of it for you to work with. The attribute is not used at run
        time.
      * Inherits   Identifies the class from which the page derives. In
        Visual Studio, this points to a class in the project assembly (.
        dll), as shown in the diagram above.

The code-behind model illustrated above is the model used by Visual
Studio. The ASP.NET Framework supports a slightly different code-behind
model for Web Forms pages. In the ASP.NET code-behind model, the visual
elements are in an .aspx file and the code is in a separate code-only
file, as in Visual Studio. However, there is no project, and the code is
not pre-compiled. Instead, the code in the .vb or .cs file is compiled
at run time, when the page is first requested by a user.

The inheritance model works as illustrated above, with the difference
that the Web Forms class (WebForm1 class in the diagram) is not part of
a project assembly. Instead, each page is a separate assembly. There is
no difference in how your code runs in the two models.

In the ASP.NET code-behind model, there is no Codebehind page attribute,
since that attribute is unique to Visual Studio. To tie the .aspx file
to its corresponding code, the page directive contains a Src attribute,
which references the file containing the source code for the file."

=============================================================

Now, I have an aspx and and ascx in this thing I am developing for mono/
linux/mod_mono. The aspx ignores the "Inherits" attribute, which the
above says it should, yet if I change the class or namespace name in
the .cs file, compile the DLL and deploy it, I get the expected "class
not found" exception on page compilation...but it pretends not to notice
that the DLL contains the code for that class, and simply acts dumb when
challenged with the facts. Of course, if I use the Src attribute, voila!
works fine.

However, the UserControl uses the Inherits attribute and finds and uses
the referenced class in the compiled DLL. 

Which is it, in Mono? Can I precompile DLLs and deploy them to the bin/
directory of the webapp (which is infinitely preferable to me), or do I
have to put all of my .cs files on the server as well? (which I
specifically do not want to do...if I have to do that I'll stick with
PHP). 

Thanks
Greg