ASP.NET 2.0: The New Compilation Model

One of the excellent features that .NET introduced was the separation of design and code in separate sections by virtue of the code-behind functionality.

A little briefing about the above model for the benefit of those who are new to .NET. In traditional ASP, one has to embed his code as well as HTML design within a single ASP Page. That means, the page would look like a chunk of codes and very difficult in debugging and even while developing, for that matter.

In .NET, the concept of Codebehind files, a way by which you can have all your application logic separately written in a file and have just design and declaration of controls in a page and relate these pages by the attribute Codebehind in the Page directive. Having said this, .NET also provided the flexibility for having the logic within the ASPX Page itself within the script tags. This was referred to as Code inline.

However, there were some hiccups in this mode.

1. The Intellisense (Autocompletion, suggestion etc.,) features were not available in the Code Inline Model.

2. The Code behind file requires compilation (rebuilding) for any changes made.

This was a little tricky because the whole application's logic lies within the DLL file (which is available in the BIN Folder of the application root) and even a small change requires rebuilding the whole application.

However, the Development Team from Microsoft has heard to the queries and have responded in a new robust compilation model.

The following are the new features available in Whidbey (Kindly note that it is still a Beta version which I am exploring and the actual functionalities may change with the release of the Original version. However, we can rest assure they would only get better with the Original version since the Developers are constantly hearing from the Evangelists and Partners and implementing their feedbacks).

1. Dynamic Compilation extended to Code-behind files.
The code-behind files don't need to be compiled for each and every change. Which means just as ASPX pages are dynamically compiled, the codebehind files are also compiled dynamically. I am sure this should be a great boon for the developers (like me) who have been complaining about rebuilding the application for small changes.

2. Intellisense and Auto-completion extended to Inline Code.
Now, whether you type your code in the codebehind file or put it in as inline code in the ASPX page, you will get the cool intellisense which can help you many times in finishing (and finding :) ) the methods. Now its up to the developer to decide which method (inline or codebehind) to follow.

3. No more control declarations in the Codebehind file.
If you examine the Codebehind files in .NET 1.x versions you will find that all the controls in the ASPX page declared are also declared in the codebehind file with the "protected" access specifier ("protected withevents" in This may introduce problems when some of these declarations are removed or don't match with that of the ASPX Pages.

Now, in Whidbey there is no more declaration of such kind in the codebehind file. That means, you declare it in one place and thats it. There will be no more declaration in the codebehind files.

There are many other features such as Precompilation Support, Intellisense and Drag n Drop in HTML View etc., which I would dicuss in future articles.

Cheers and Happy Progamming !!!

Print | posted on Monday, April 25, 2005 8:02 AM

Comments on this post

No comments posted yet.

Your comment:

 (will show your gravatar)