Friday, December 22, 2006

disable debugging before placing your application into production

Make sure that you disable debugging before placing your application into production. When an application is compiled in debug mode, the compiler can't make certain performance optimizations.

Dynamic Compilation

Strangely enough, when you create an ASP.NET page, you are actually creating the source code for a .NET class. You are creating a new instance of the System.Web.UI.Page class. The entire contents of an ASP.NET page, including all script and HTML content, are compiled into a .NET class.

When you request an ASP.NET page, the ASP.NET Framework checks for a .NET class that corresponds to the page. If a corresponding class does not exist, the Framework automatically compiles the page into a new class and stores the compiled class (the assembly) in the Temporary ASP.NET Files folder located at the following path:

\WINDOWS\Microsoft.NET\Framework\[version]\Temporary ASP.NET Files

The next time anyone requests the same page in the future, the page is not compiled again. The previously compiled class is executed and the results are returned to the browser.

Even if you unplug your web server, move to Borneo for 3 years, and start up your web server again, the next time someone requests the same page, the page does not need to be re-compiled. The compiled class is preserved in the Temporary ASP.NET Files folder until the source code for your application is modified.

When the class is added to the Temporary ASP.NET Files folder, a file dependency is created between the class and the original ASP.NET page. If the ASP.NET page is modified in any way, the corresponding .NET class is automatically deleted. The next time someone requests the page, the Framework automatically compiles the modified page source into a new .NET class.

This process is called dynamic compilation. Dynamic compilation enables ASP.NET applications to support thousands of simultaneous users. Unlike an ASP Classic page, for example, an ASP.NET page does not need to be parsed and compiled each and every time it is requested. An ASP.NET page is compiled only when an application is modified.

Note

You can precompile an entire ASP.NET application by using the aspnet_compiler.exe command-line tool. If you precompile an application, users don't experience the compilation delay resulting from the first page request.

Control State

The ASP.NET Framework version 2.0 includes a new feature called Control State. Control State is similar to View State except that it is used to preserve only critical state information. For example, the GridView control uses Control State to store the selected row. Even if you disable View State, the GridView control remembers which row is selected.

Handling Page Events

PreInit

Init

InitComplete

PreLoad

Load

LoadComplete

PreRender

PreRenderComplete

SaveStateComplete

Unload

Overview of ASP.NET Controls

Standard Controls :Button,Label
Validation Controls:RequiredFieldValidator
Rich Controls:banner advertisements,calendars,file upload buttons,multi-step wizards.
Data Controls:
Navigation Controls:tree views,bread crumb trails
Login Controls:change password,login,registration
Web Part Controls:
HTML Controls :

Namespace ASP.NET 2.0

A namespace is simply a category. For example, all the classes related to working with the file system are located in the System.IO namespace. All the classes for working a Microsoft SQL Server database are located in the System.Data.SqlClient namespace.

Understanding Assemblies

An assembly is the actual .dll file on your hard drive where the classes in the .NET Framework are stored. For example, all the classes contained in the ASP.NET Framework are located in an assembly named System.Web.dll.
Each class entry in the .NET Framework SDK documentation lists the assembly and namespace associated with the class. For example, if you look up the MessageQueue class in the documentation, you'll discover that this class is located in the System.Messaging namespace located in the System.Messaging.dll assembly.

Understanding web.config

A web configuration file is a special type of file that you can add to your application to configure your application.
Be aware that the file is an XML file and, therefore, all the tags contained in the file are case sensitive.
You can add a web configuration file to your application by selecting Website, Add New Item and selecting Web Configuration File

Send() Vs SendAsync()

The SmtpClient class also includes two methods you can use to send an email:
Send() and SendAsync().
The Send method blocks further program execution until the send operation is completed.
The SendAsync() method, on the other hand, sends the email asynchronously.
Unlike the Send() method, the SendAsync() method does not wait to check whether the send operation was successful.