Ask a question
Monday, 21 September 2009 14:21

The Pulsing Heart of ASP.NET AJAX

Configuration of ASP.NET AJAX

When you create the project of an AJAX-enabled ASP.NET Web site, everything looks like a classic ASP.NET application at first glance. After a second look, though, you can see that the configuration file contains some changes in the form of new sections and new runtime components. In particular, the runtime components-made-to-measure HTTP modules and HTTP handlers-play a key role in the implementation of ASP.NET AJAX.

The web.config File

In ASP.NET, the web.config file stores application settings that apply to the folder where it is located and to child subfolders. Each application can have a variety of web.config files to apply different settings at different folder levels.

The web.config file is a text file written in accordance with a well-known XML schema. The standard schema file features a built-in number of sections and elements, but new sections can be added to configure custom services and components. As mentioned, ASP.NET AJAX Extensions 1.0 is just an extension to ASP.NET, and it can be easily seen as a new service that requires its own set of extensions to the configuration syntax.

New Configuration Sections

The ASP.NET configuration file has a root element named . A particular configuration file that contains information for a custom service can optionally define new sections. All nonstandard sections used in a configuration file must be declared in the initial section. The following code snippet shows the new sections defined in the root web.config file of an ASP.NET AJAX application:

New Configuration Sections

As you can see, everything goes under the section which, in turn, is a child of  . Under the section, you find another child section named . Let’s dig out the section first.

The Section

The section might contain a child section named . The child section determines how ASP.NET AJAX system scripts should be served to the client and handled. The section features two attributes: enableCaching and enableCompression. Both are Boolean values and are set to true by default:

  

The enableCaching attribute indicates whether the system script files (as well as any other linked scripts and resources) are to be cached locally or downloaded for each request. System script files are a key element of AJAX frameworks, and ASP.NET AJAX Extensions is no exception. The more the framework is rich with features, the more the size of such script files becomes large.

To keep the overall size of system script files below the threshold of a few KBs, compression is required. You can enable or disable compression through the enableCompression attribute. When the attribute is turned on, script files that are embedded as resources in an assembly and string resources are compressed.

Published in .NET