[Monodevelop-devel] [Path] Updated ASP.NET Templates

Michael Hutchinson m.j.hutchinson at gmail.com
Mon Jul 14 22:10:23 EDT 2008

On Mon, Jul 14, 2008 at 12:36 PM, Valentin Sawadski
<valentin.sawadski at googlemail.com> wrote:
>> Actually, the CodeFile attribute is only needed when the codebehind
>> files are intended to be compiled on the server (as VS Express <
>> 2008sp1) does it. The full VS (and VS Express 2008sp2) supports Web
>> Projects, where the CodeBehind is compiled beforehand. MonoDevelop
>> uses the latter model.
> Thats odd, because MSDN
> (http://msdn.microsoft.com/en-us/library/ydy4x04a(VS.80).aspx) does not
> mention this. It only states that:
>        "This attribute is included for compatibility with previous
>        versions of ASP.NET, to implement the code-behind feature. In
>        ASP.NET version 2.0, you should instead use the CodeFile
>        attribute to specify the name of the source file, along with the
>        Inherits attribute to specify the fully qualified name of the
>        class."

The CodeBehind attribute is only used by Visual Studio 2002/2003. All
versions of ASP.NET are aware of it, and totally ignore it. It can be
omitted, and won't affect anything.

The CodeFile attribute is used by ASP.NET 2.0 for the "2005" model,
where the CodeBehind class is compiled on the server. It specifies the
CodeBehind file that should be compiled when the page is compiled. In
this model, a partial class is generated and compiled together with
the CodeBehind class that's defined in the CodeFile.

The Inherits attribute is used in ALL compilation models to specify
the class from which the compiled page should inherit. It can be
System.Web.UI.Page or ANY class that derives from this, in ANY of the
referenced assemblies. If you have the CodeFile attribute, it can be
defined in a file compiled on the fly. Having these classes "grouped"
in the IDE (Default.aspx.cs etc) with the corresponding is simply a
convenience that MonoDevelop and Visual Studio provide. Ultimately
they all get compiled down into on application dll from which the aspx
compiler can reference them.

Note that although the CodeFile ("Web Site") model was introduced with
ASP.NET 2.0 and VS 2005, many developers considered it to be inferior
for serious applications, and hence Microsoft introduced an addin for
2005 that added support for the old-style "Web Projects", and included
it with 2008 by default. They've even added it to VS Express in
2008sp1, since the "web projecy" model is required for the upcoming
MVC style of development.

> Anyways, this does not change the fact that the current Templates do not
> work with xsp and xsp2 out of the box. Adding CodeFile to them fixes
> this.

They work just fine, as long as you compile the project first. MD
doesn't yet explicitly support the "web site" model. I plan to support
it to some extent (but maybe only as an importer -- I have a limited
amount of time, and MVC is likely to become the most important
development style anyway).

When designing the initial ASP.NET support for MD back in 2006, I
investigated the ASP.NET compilation models very thoroughly, and I'm
glad the one I chose seems to have become the preferred choice for
future development. The "web site" model is cute but it's not really
suited to serious development (VCS, deployment, etc). It was basically
an attempt to make ASP.NET more like PHP ;-)

I'd be happy to add your templates as an alternate set but they won't
replace the existing ones. I'm not sure how to prevent confusion
between the two kinds though :-/


Michael Hutchinson

More information about the Monodevelop-devel-list mailing list