Lesson 3: Where Does Processing Occur?

Lesson 3: Where Does Processing Occur?

As you know from the previous lesson, Web applications run on a server. But Web applications aren t like Windows applications, which start when the user invokes an executable file and end when the user closes the application. Instead, Web applications start when a browser requests a Web page and end when no more requests are made.

After this lesson, you will be able to

  • Use folder structure to define the boundaries of an application

  • Set a start page for your application in Visual Studio and set a default document for your application in IIS

  • Explain how ASP.NET manages application processes

  • Set the time-out value that indirectly determines when an application ends

Estimated lesson time: 15 minutes

Application Boundaries and Start Pages

IIS defines a Web application as any file that is executed within a set of folders on your Web site. The boundaries of a Web application are determined by its folder structure. The application boundary starts in the root application folder, which contains the application s start page, its Web.config file, and the /bin folder containing the application s assembly. The application ends at the last subordinate folder or when another root application folder is encountered. Figure 2-17 shows several separate applications.

figure 2-17 web application boundaries in iis

Figure 2-17. Web application boundaries in IIS

When Visual Studio .NET creates a new Web application project, it creates a new folder for the project and identifies the first Web form in the project (Webform1.aspx) as the start page. A start page is a page designated by Visual Studio as the first page to display in your application. All of the subordinate folders, such as /bin, are part of that application.

If your application design changes during development, or if you just want to quickly run the current page during debugging, you might want to change the start page of your application.

To set a different Web form or HTML page as the start page, do the following:

  • In Solution Explorer, right-click the Web form or HTML page you want to specify as the start page of your application, and choose Set As Start Page on the shortcut menu.

When you are ready to deploy your Web application, you will usually want to set the application s start page as its default document in IIS. The IIS default document is the page that IIS displays if the user omits the document name as part of his or her requested address. By default, IIS specifies these default document file names: Default.htm, Default.asp, Index.htm, and Iisstart.asp.

To set your application s start page as the default document in IIS, either rename the start page to one of the file names in the preceding list, or add the start page s file name to the IIS default document list by following these steps:

  1. In the IIS management console, select the Web application in the console tree, and the choose Properties from the Action menu. The Web site s Properties dialog box opens.

  2. On the Documents tab of the Properties window, click Add. The Add Default Document dialog box opens and allows you to add the name of your application s start page to the default document list, as shown in Figure 2-18.

    figure 2-18 the add default document dialog box

    Figure 2-18. The Add Default Document dialog box

  3. In the Add Default Document dialog box, type the name of your document and click OK. Click OK to close the Web site s Properties window.

The order of the file names shown in Figure 2-18 determines the precedence of default documents. IIS checks for these documents in the order shown and displays the first document that matches.

How IIS and ASP.NET Manage Processes

Understanding application boundaries is important because ASP.NET uses these boundaries to determine how your application is run on the server. When IIS receives a request for a resource within a Web application, IIS uses aspnet_isapi.dll to call the ASP.NET worker process (aspnet_wp.exe). The ASP.NET worker process loads the Web application s assembly, allocating one process space, called the application domain, for each application.

In this way, ASP.NET maintains process isolation for each Web application. This is different from the way IIS provided different isolation levels for older Active Server Pages (ASP) applications running under DLLHost.exe. The isolation level settings in IIS have no effect on ASP.NET applications.

In IIS version 6.0, you will be able to configure multiple application pools, each of which can be served by one or more process instances (w3wp.exe). In addition, ASP.NET is integrated with the IIS version 6.0 kernel mode HTTP listener, which will allow requests to pass directly from the operating system to the ASP.NET worker process. For more information about IIS version 6.0, see the TechNet article http://www.microsoft.com/technet/prodtechnol/iis/evaluate/iis6ovw.asp.

Determining When an Application Ends

When a user requests a page from a Web application for the first time, IIS starts the Web application, if it is not already running, and creates a session for that user. All of the subsequent requests made by that user are part of the same session. Sessions are important for two reasons:

  • They allow ASP.NET to keep user-specific data called the Session state. Session state and Application state are explained in Lesson 2.

  • They determine when the application ends. When the last session ends, IIS ends the application.

How long a session lasts is determined by a time-out value set in your project s Web.config file. The default is 20 minutes. That means that 20 minutes after a user makes his or her last request to an application, the user s session ends. When there are no more sessions, the application ends.

Remember that IIS defines a Web application as any file that is executed within a set of folders on your Web site. So if a user requests any of the .aspx files in that application s set of folders within 20 minutes, that user s session is maintained.

NOTE
You have only indirect control over when an application ends through the session time-out. It is important to understand this because the session timeout controls the life cycle of the application on the server.

Reducing the session time-out value can free up resources on the server because session data expires more quickly. However, setting the value too low can cause sessions to time out while they are still being used.

To change the session time-out value, follow these steps:

  1. Open the project in Visual Studio .NET.

  2. Open the Web.config file by double-clicking it in the Solution Explorer window.

  3. Edit the time-out value (shown in boldface) in the following line in the file:

    <sessionState mode="InProc" stateConnectionString="tcpip=127 .0.0.1:42424" sqlConnectionString="data source=127.0.0.1;use r id=sa;password=" cookieless="false" timeout="20" />

  4. Save the file.

Any changes to the Web.config file automatically restart the Web application. If you change the Web.config file on a deployed Web application, Application state and Session state variables are lost for any current users.



MCAD(s)MCSD Self-Paced Training Kit(c) Developing Web Applications With Microsoft Visual Basic. Net and Microsoft V[.  .. ]0-315
MCAD(s)MCSD Self-Paced Training Kit(c) Developing Web Applications With Microsoft Visual Basic. Net and Microsoft V[. .. ]0-315
ISBN: N/A
EAN: N/A
Year: 2003
Pages: 118

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net