ASP.NET 2.0 (III) Architecture and Tools...
This article is the third in a series. In this third article we'll take a look at the changes to the architecture of ASP.NET v2.0. In particular we’ll look at the changes to the compilation and deployment model.
In this third article we'll take a look at the changes to the architecture of ASP.NET v2.0. In particular we'll look at the changes to the compilation and deployment model. We'll also take a quick look at the tool support provided by Visual Studio .NET 2005. In subsequent articles we'll then look in more detail at areas introduced in the first 3 articles and get into a little more code than these first three overviews have allowed.
Note that the information presented is based on the Beta product so minor changes may have been introduced in the final product release.
ASP.NET v2.0 provides automatic compilation for satellite code via a code directory. All
files within this directory will be compiled on the first run. Files therein can include
WSDL and XSD files, for example, as well as .vb and other ‘pure code’ files.
Also provided is pre-compilation of the entire web site, including web pages. This both
improves start up performance and protects intellectual property.
Note that instead of the content page inheriting from the code behind page, we now specify
which code behind page is to be compiled with the content file. This is actually a
fundamental change at the CLR level. Version 2.0 of the CLR provides support for partial
classes, where the same class can span multiple files. This allows the code separation page
to be simpler as it can be part of the same page as the content page, meaning protected
variables are not required to reference the controls on the page and the Designer does not
need to write code into the code behind file.
A few new keywords are introduced with these changes: Partial to designate code is part of
a class. For the aspx the compileWith attribute defines the physical file containing the
code to compile along with the aspx.
ASP.NET 1.x already supports dynamic compilation of aspx and ascx files, eliminating the need
for a specific compilation step. Other files required manual/ tool driven compilation
however. ASP.NET 2.0 extends this model to other files: classes, Web Services, typed data
sets, master pages, resource files and themes. To do so the developer must use specific
reserved folders:
There is no restriction on creating sub-directories within these folders to organize your
code.
The assemblies created are not placed in the \bin directory – there is no need for the \bin
though it can still be used for scenarios where dynamic compilation is not required or
supported. Automatically compiled assemblies are placed in a folder managed by
ASP.NET.
The dynamic compilation system is configurable via web.config. Further the build process
itself is extensible.
Applications can be precompiled. In place pre-compilation is achieved via:
http://applicationDirectory/precompile.axd
This precompiles (changed) files. Errors that occur in pre-compilation will halt the entire
process. The errors appear in the browser window exactly as if the page had been
hit.
To deploy the application without source the aspnet_compiler.exe tool is provided. Such
precompilation does not compile static files such as HTML, web.config, XML, etc. These are
just copied to the target directory. As are the contents of the /bin directory.
If any changes are required to the target application the process must be initiated
again.
There is a compilation API – ClientBuildManager – which allows custom tools to be built to
manage the build process.
With ASP.NET 2.0 comes Visual Studio.NET 2005 which has been particularly improved for the
web developer. There is also a stand alone development tool targeted specifically at web
developers (think web matrix): Visual Web Developer Express Edition. Basically the latter
is aimed at those who don’t want to pay for the full Visual Studio product.
Among the new features/ changes to VS.NET are:
There are also the following more minor changes:
Note that the Visual web developer express edition does not include the following:
Most of which will not be great issues the majority of the time.
In this article we've looked at the architectural changes new to ASP.NET 2.0 in overview as well as the changes in Visual Studio. In the next article we'll start looking in more depth at ASP.NET 2.0 considering data source controls and data binding.
ASP.NET v2.0 – the Beta Version
Homer et al.
Addison-Wesley