Apologies for flying so high. I have done .NET so long (since 2000, so I
guess not SO long) that I often forget that the topics I now find simple are
not so simple. I will back up a bit and cover the info a bit better. If I am
still flying too high, just ask questions. Unlike Mr. Spencer, I already ate
today, so I am unlikely to take a chomp in the wrong places.
-----------------------------
NOTE: I know Kevin well, and have the utmost respect for his skill. As such,
I will undoubtably be zinged for that comment. Despite being testy at times,
he is a nice guy.
-----------------------------
There are a couple of ways to architect an application. The first is flat,
where all of the code is in a single ASP .NET project. The second is to move
code that does not directly affect what is painted in the browser to other
projects. Most typically, you see people moving data code to data projects
and business rules code to another project.
In the three-tier (or n-tier) approach, you compile the business and data
projects separately from the web application. In this model, you can create
a strong name using the command line tool sn.exe from a .NET command prompt.
You then can use the strong name key and run ngen.exe to create native
binaries.
Another step back, just to be safe. The difference between .NET compiled
software and ngen'ed software is the .NET stuff still has to be JIT compiled
to run. What this means is your building creates a type of code that can be
run on any machine with .NET (Windows, BSD and Linux). The code is compiled
for the particular OS when it is first run, thus JIT (or Just In Time). When
you run ngen.exe, you make a piece of software that has already run through
the JIT compile and talks in the language of the particular OS it is running
on. No 15 second JIT compile any more.
There is a tool called nAnt, which is worthy of learning.
http://sourceforge.net/projects/nant/
nAnt can precompile your non-Ngened projects by running a simple tool. It is
not the easiest to learn, but it is worthwhile if you have lots of code in
your ASP.NET page and cannot stand a 15-210 second initial hit when it is
JIT compiled.
When the next version of .NET comes out in 2005, you will have the ability
to easily precompile complete applications. I wish the feature was available
today, but it is not. I use nAnt myself, although I have also been known to
set up WAST (the Web Applications Stress Tool - a free download available
from Microsoft at one time, do a search). I set it up a test that hits each
page and set it up for a very short time forcing compile). Another cheap way
to compile everything is to set up a frameset with all of the pages in it.
Put it on your local box. When you stick a new build on the server, hit the
frameset once. Everything builds and your customers get quick response
times.
There is one other way to reduce the hit, if the code branches. What I mean
is something like:
A. If I hit the page and I am not logged in, it runs routine A
B. If I am logged in, it runs routine B
On the first hit, the Page_Load event, along with routine A are compiled,
but you do not take a hit for B. Then, you take a small hit for B only when
you log in. To take advantage of this type of compilation, you still have to
divide out the code, which is a bit more advanced. If you are going to this
degree, you might as well divide into separate projects.
--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
************************************************
Think Outside the Box!
************************************************