Managing ASP.NET


Every Web administrator should become intimately familiar with ASP.NET. You should know how to configure ASP.NET and how to manage ASP.NET applications. ASP.NET configurations and applications are fairly complex. You’ll need to work closely with your organization’s engineering department during planning, staging, and deployment.

Installing ASP.NET

To use applications that incorporate the Microsoft Windows .NET Framework, you must install ASP.NET on your IIS servers. ASP.NET is the central Windows component that allows an IIS server to run ASP.NET applications. Like the .NET Framework, ASP.NET technology is advancing rapidly. Several implementations of ASP.NET are already available, and many more will be developed in the coming months and years.

Unlike many application implementations, where you have to remove previous application or component versions before installing new applications or components, you don’t have to remove previous versions of ASP.NET. The reason is that the .NET Framework supports side-by-side execution of applications and components running different versions of ASP.NET. Side-by-side execution is made possible because applications and the components they use run within isolated process boundaries. Each worker process runs its own instance of the ASP.NET components that it needs and is isolated from other processes.

You can check to see if ASP.NET is installed on a server by using the IIS snap-in. Follow these steps:

  1. Select the Web Service Extensions node in the IIS snap-in.

  2. If ASP.NET is installed, you’ll see a Web Service Extension entry for each version of ASP.NET installed on the server.

To install the version of ASP.NET that ships with Windows Server 2003, you use the Windows Component Wizard by completing the following steps:

  1. Click Add Or Remove Programs in Control Panel and then click Add/ Remove Windows Components. This starts the Windows Component Wizard.

  2. Select Application Server and then click Details. In the Application Server dialog box, shown in Figure 6-1, check the ASP.NET check box and any other application server components you want to install.

    click to expand
    Figure 6-1: ASP.NET isn’t installed by default when you install an Application Server. You must choose ASP.NET as one of the installation components.

    Note

    Make sure you don’t accidentally clear the Application Server check box when selecting it, which is easy to do.

  3. Click OK.

  4. Click Next and then, when prompted, click Finish.

Installing ASP.NET results in several Windows components and resources being installed as well. These include:

  • ASP.NET Performance Counters Each version of ASP.NET installed on a server has a different set of performance counter objects that are associated with it. These performance counters are installed when the ASP.NET version is installed.

  • ASP.NET State Service ASP.NET uses this service to manage session states. All compatible versions of ASP.NET installed on a server use the same state service, which is provided by the most recent version of ASP.NET installed on the computer.

  • ASP.NET SQL State Server ASP.NET uses the SQL State Server in conjunction with the ASP.NET State Service. All compatible versions of ASP.NET installed on a server use the same state server, which is provided and managed by the most recent version of ASP.NET installed.

  • ASPNET Local User Account On stand-alone and member servers, a local user account called ASPNET is created when you install ASP.NET. Worker processes use this account on the local machine when running in IIS 5 isolation mode. If the server is part of a domain, worker processes are configured to use the Network Service account.

Running Side-by-Side ASP.NET Configurations

You can install multiple versions of ASP.NET on an IIS server. Typically, you do this by running the .NET Framework setup program (Dotnetfx.exe) for the version you want to install. Installing a newer version of the .NET Framework could reconfigure ASP.NET applications installed on the IIS server to use the version you’re installing. Specifically, this happens when the version you’re installing is a new version that represents a minor revision (as determined by the version number). For example, if ASP.NET applications are currently configured to use ASP.NET version 1.1.4322 and you’re installing a newer version, ASP.NET applications would be configured to use components in the new version automatically. Here, 4322 represents the build number and 1.1 are the major and minor version numbers, respectively.

After you install a new version of the .NET Framework, you’ll need to configure IIS so that the new version of ASP.NET it contains can be used. You do this by completing the following steps:

  1. Access the Web Service Extensions node in the IIS snap-in.

  2. In the right pane, click the Web Service Extension entry for the ASP.NET version you installed and then click Allow.

Each version of the .NET Framework installed on a server has different components and tools. The base directory for the .NET Framework is %SystemRoot%\Microsoft.NET\Framework. Below the base directory, you’ll find separate subdirectories for each version of the .NET Framework you’ve installed.

One of the tools in the version subdirectory is the ASP.NET IIS Registration tool. This tool controls the mapping of ASP.NET applications to a specific ASP.NET version. If you want to install an ASP.NET version so that it can be used on the server, you can use this tool to do it. Complete the following steps:

  1. Display the Run dialog box by clicking Start and then choosing Run.

  2. Type cmd in the Open field and then click OK.

  3. In the command console, type cd %SystemRoot%\Microsoft.NET\ Framework.

  4. Type dir to obtain a directory listing. Note the available version subdirectories and then change to the directory containing the ASP.NET version you want to use.

  5. List the installed versions of ASP.NET and view how those versions are configured by typing aspnet_regiis –lv and then typing aspnet_regiis –lk.

  6. If you want a single ASP.NET application to use this ASP.NET version, type aspnet_regiis –sn MetabasePathLocation, where MetabasePathLocation is the metabase path to the application you want to use this version of ASP.NET. See Chapter 15, “IIS Optimization and the Metabase,” for details on working with the IIS metabase.

  7. If you want all ASP.NET applications to use this ASP.NET version (provided that it’s a newer version and represents a compatible build as determined by the version and build number), type aspnet_regiis –i.

  8. If you want to register this ASP.NET version on the server but don’t want to reconfigure applications to use it, type aspnet_regiis –ir.

    Tip

    It’s important to that each version of ASP.NET installed on a server has a separate set of performance counter objects. Because of this, if you want to monitor a particular ASP.NET application’s performance, you’ll need to configure monitoring of the performance counter objects specific to the version of ASP.NET used by the application.

Defining ASP.NET Directory Structures and Applications

Every ASP.NET application has an application root directory. This root directory is created in the IIS snap-in as a virtual directory that defines the application alias and the physical directory in which application components are stored. In the root directory, you’ll store files needed by the application. You’ll need a Bin subdirectory for the application as well, which is used to store assemblies (compiled binary files) and other dynamic-link libraries (DLLs) used by the application.

To create the directory structures for an ASP.NET application, follow these steps:

  1. In the IIS snap-in, expand the Web Sites node. Right-click the Web site on which you want to define the ASP.NET application, choose New, and then click Virtual Directory. This starts the Virtual Directory Creation Wizard. Click Next.

  2. In the Alias field, type the name of the application as shown in Figure 6-2. The best application names are short but descriptive. Click Next.

    click to expand
    Figure 6-2: The virtual directory alias sets the name of the application.

  3. The next page lets you set the path to the physical directory where the application content is stored. Type the directory path or click Browse to search for a directory. The directory must be created before you can select it. If necessary, click Browse and then click Make New Folder to create the directory before you select it. However, don’t forget about checking and setting permissions at the operating system level as discussed in Chapter 7, “Managing Web Server Security.”

  4. Click Next, and then set access permissions for the applications. Normally, you’ll want to set Read and Run Script permissions only. The standard permissions are these:

    • Read Allows users to read documents, such as Hypertext Markup Language (HTML) files.

    • Run Scripts Allows users to run scripts, such as Active Server Pages (ASP) files or Perl scripts.

    • Execute Allows users to execute programs, such as Internet Server Application Programming Interface (ISAPI) applications or executable files.

    • Write Allows users to upload files to the site, such as with Microsoft FrontPage.

    • Browse Allows users to view a list of files if they enter the name of a valid directory that doesn’t have a default document.

  5. Click Next and then click Finish. The virtual directory for the application is created.

  6. Using Windows Explorer, create a Bin subdirectory under the main application directory. This directory is used as the local assembly cache. For more information on the assembly cache, see the section of this chapter entitled “Working with the Assembly Cache.”

  7. Configure the application to use a specific application pool and then optimize the application pool configuration as discussed later in this chapter.

  8. Deploy the application by copying the application files into the appropriate directories. For more information on deploying applications, see the section of this chapter entitled “Deploying ASP.NET Applications.”

Working with the Assembly Cache

ASP.NET applications can make use of many types of components. Some components, like .asmx and .aspx files, are compiled at runtime by ASP.NET when they’re first requested, and then the compiled code is stored in the file cache where it can be reused without recompiling. Other components, like assemblies, must be precompiled into DLL binaries and placed in the appropriate assembly cache before they can be used.

Binary components that are specific to an application are stored in the local assembly cache. You don’t need to register components in the local assembly cache. To use local assemblies, you must create a Bin directory under the main application directory and then copy the necessary binaries and assemblies into this subdirectory. You can copy files using Windows Explorer or using a command-line copy tool such as Xcopy.

Binary components that are shared between applications are called global assemblies. To use global assemblies, you must register them in the global assembly cache. For production servers, you configure the installation using Microsoft Windows Installer (MSI) 2. For testing and development purposes, you can use the Global Assembly Cache Tool (Gacutil.exe) to perform this task. You can find this tool in the subdirectory for the ASP.NET version you’re working with, %SystemRoot%\Microsoft.NET\Framework\VersionNumber.

To use the Global Assembly Cache Tool to install a global assembly, follow these steps:

  1. Display the Run dialog box by clicking Start and then choosing Run.

  2. Type cmd in the Open field and then click OK.

  3. In the command console, type cd %SystemRoot%\Microsoft.NET\ Framework.

  4. Type dir to obtain a directory listing. Note the available version subdirectories and then change to the directory containing the ASP.NET version you want to use.

  5. Type gacutil –i AssemblyFilePath where AssemblyFilePath is the complete file path of the assembly to install in the global assembly cache.

Deploying ASP.NET Applications

Now that you’ve configured the application directory structure, you’re ready to deploy your ASP.NET applications. You deploy applications by copying the necessary ASP.NET files, such as .asmx or .aspx files, to the application directory. Application binaries and assemblies (DLLs) are copied to the Bin subdirectory for the application.

Anytime you need to update or change the files in the deployment directory, you simply copy the new versions of the ASP.NET files and binaries to the appropriate directory. When you do this, ASP.NET automatically detects that files have been updated. In response, ASP.NET compiles a new version of the application and loads it into memory as necessary to handle new requests. Any current requests are handled without interruption by the previously created application instance. When that application instance is no longer needed, it’s removed from memory.

ASP.NET handles changes to the Web.config file in the same way. If you modify the Web.config file or application pool properties while IIS is running, ASP.NET compiles a new version of the application and loads it into memory as necessary to handle new requests. Any current requests are handled without interruption by the previously created application instance. When that application instance is no longer needed, it’s removed from memory.

If you need to install components in the global assembly cache, you’ll need to follow the procedures discussed in the previous section.

Uninstalling ASP.NET Versions

Sometimes you’ll no longer want an older version of ASP.NET to run on a server. In this case you can uninstall the ASP.NET version that’s no longer needed. When you uninstall an older version of ASP.NET, ASP.NET applications that used the version are reconfigured so that they use the highest remaining version of ASP.NET that’s compatible with the version you’re uninstalling.

Remember, the version number determines compatibility. If no other compatible versions are installed, applications that used the version of ASP.NET you’re uninstalling are left in an unconfigured state, which might cause the entire contents of ASP.NET pages to be served directly to clients, thereby exposing the code those pages contain.

If you want to uninstall a version of ASP.NET, follow these steps:

  1. Display the Run dialog box by clicking Start and then choosing Run.

  2. Type cmd in the Open field and then click OK.

  3. In the command console, type cd %SystemRoot%\Microsoft.NET\ Framework.

  4. Type dir to obtain a directory listing. Note the available version subdirectories and then change to the directory containing the ASP.NET version you want to use.

  5. List the installed versions of ASP.NET and view how those versions are configured by typing aspnet_regiis –lv and then typing aspnet_regiis –lk.

  6. To uninstall the ASP.NET version whose components are in the current subdirectory, type aspnet_regiis –u. This uninstalls the ASP.NET version and the performance counter objects used by the ASP.NET version.

    Note

    If you want to install all ASP.NET versions installed on a server, type aspnet_regiis –ua.

When you uninstall ASP.NET, the following Windows components and resources might also be uninstalled:

  • ASP.NET Performance Counters Performance counters for the ASP.NET version are uninstalled.

  • ASP.NET State Service If the ASP.NET version you’re uninstalling is the most recent version of ASP.NET installed on the computer, the ASP.NET State Service of the ASP.NET version with the next highest version number is used. If this is the last ASP.NET version on the computer, the ASP.NET State Service is uninstalled.

  • ASP.NET SQL State Server If the ASP.NET version you’re uninstalling is the most recent version of ASP.NET installed on the computer, the ASP.NET SQL State Server of the ASP.NET version with the next highest version number is used. If this is the last ASP.NET version on the computer, the ASP.NET SQL State Server is uninstalled.

  • ASPNET Local User Account If you’re uninstalling the last ASP.NET version on a stand-alone or member server, the ASPNET local user account is deleted.




Microsoft IIS 6.0Administrator's Consultant
Microsoft IIS 6.0Administrator's Consultant
ISBN: N/A
EAN: N/A
Year: 2003
Pages: 116

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