Team LiB
Previous Section Next Section

Integrating ASP.NET with IIS

Before we leave this chapter, we will briefly look at ASP.NET. When you use ASP.NET, all clients communicate with ASP.NET through IIS, as shown in Figure 7-18.

Click To expand
Figure 7-18: Communication between IIS, ASP.NET, and the operating system

ASP.NET hosts the runtime environment to provide for a scalable server-side operation of managed code. It provides the opportunity to use both Web forms and Web services on your Web servers by working directly with the .NET runtime. ASP.NET is, however, more than just a host for the runtime. It offers a complete architecture for developing both Web sites as well as distributed objects. IIS and ASP.NET are the publishing mechanisms for applications, and both have supporting classes in the .NET Framework.

An ASP.NET application is simply all the files, folders, and content in a virtual directory in IIS. ASP.NET applications are processed in a single instance of aspnet_wp.exe, which is the ASP.NET worker process. When a request for an ASP.NET file type is made, the ISAPI extension aspnet_isapi.dll handles them. This DLL file runs in the inetinfo.exe process address space. It is actually IIS that maps the file requests to aspnet_isapi.dll (see Figure 7-19), even though ASP.NET has its own object model, session state scheme, and process isolation scheme.

Click To expand
Figure 7-19: How aspnet_isapi.dll maps file requests to aspnet_wp.exe

The request is then forwarded by aspnet_isapi.dll to aspnet_wp.exe. Figure 7-20 shows how the ASP.NET worker process handles the request internally.

Click To expand
Figure 7-20: The flow inside the ASP.NET worker process

The HTTPRuntime object starts the processing chain, and the HTTPContext object conveys details about the request and the response generated throughout the lifetime of the request. Some of these details are exposed to external actors as properties. After the HTTPRuntime object has examined the request, it passes it on to the correct instance of an HTTPApplication object for further processing. When the HTTPApplication object is finished, it passes the request to one or more HTTPModule objects. These objects provide services like state management, authentication, and output caching. You can also create your own module objects to provide for a flexible request processing architecture. Finally the HTTPHandler object processes the request before the response is sent back to the caller. There is one HTTPHandler for *.aspx files, another for *.asmx files, and so on.

Note 

Each virtual directory in the IIS represents one application domain (AppDomain(s) in Figure 7-20).You can say that ASP.NET treats individual virtual directories as individual applications, if you like. Each application domain contains a pool of HTTPApplication objects, and there is a separate HTTPApplication object created to handle each simultaneous request. They are pooled for performance reasons.

Many of the scalability, reliability, and performance features of ASP.NET are already built into IIS 6.0. This is, of course, the result of the integration of the .NET Framework in Windows Server 2003. On an IIS 5.0 system, ASP.NET will add features that help you develop better, more reliable applications. For instance, it provides an out-of-process execution model that protects the server process from user code. Remember, this makes it harder for application errors in user code to bring down the entire server. Other features ASP.NET provides are two models for process recycling. The first, called reactive process recycling, restarts the process when certain symptoms occur. These symptoms can be deadlocks, access violations, memory leaks, and more. The conditions to trigger a process restart can be controlled by the administrator to suit a certain application environment. The other recycling model, proactive process recycling, simply works by periodically restarting a process, even if the process is healthy. This can be of great use to minimize denial of service due to undetected conditions. You can configure this restart to occur after a specific number of requests or after a certain time-out period.

With ASP.NET you also get the benefit of having a Web garden as mentioned earlier in the chapter. If using this configuration, you need to choose an out-of-process provider (NT Service or SQL) for maintaining session state, however. Also keep in mind that application state, statics, and caching is per application domain and not per computer.


Team LiB
Previous Section Next Section