Using IIS
Home Chapter One Chapter Two Chapter Three Chapter Four Chapter Five Chapter Seven Using IIS

 

This lesson does not correspond to any chapter in the text. However, it's a valuable resource to help you get IIS up and running on your home machine!

WEB SERVERS AND YOU

Web servers run special software to support HTTP, FTP and mail access. Microsoft's Web server is Internet Information Server (IIS). You need IIS on the computer you're developing ASP.NET pages because you should NEVER do your development on the actual server that will be hosting the site. Errors could lead to server crashes. Using other applications might slow down the server. You might even accidentally overwrite your entire site. The bottom line is that you should perfect your Web site on a development computer. Only then should it be uploaded to a live server.

In order to create ASP.NET applications on your PC, it must act as a Web server. You will access your ASP.NET pages just as you would over the Internet, by entering a URL into your Web browser. ASP.NET pages will be accessed by IIS and processed by the ASP.NET engine. The only difference between your local PC and a traditional Web server is that your PC won't be accessible over the Internet.

IIS is included with Windows NT, Windows 2000 and Windows XP Professional or greater. PWS will not work with ASP.NET pages. Therefore if you don't have one of the operating systems listed above, you can't create ASP.NET sites unless you use the free ASP.NET Web Matrix. You can always look for a free host to test your pages. It looks like DevBizHost.com might offer free hosting, but you should check into it before wasting your time.

IIS is not installed by default. You should make sure it's installed before installing the .NET Framework or Visual Studio.NET. Otherwise you have to run the two installation scripts

Once IIS is installed a virtual directory is created at C:\Inetpub\wwwroot. If a file named localstart.asp is found in that directory, IIS is up and running. You can't double click on this file to run it. It must be executed through IIS by requesting it using a URL. You can double click on an HTML file in Windows Explorer because it does not need to be accessed through the Web Server and compiled by ASP.NET.

Since you are running IIS on the same computer you are accessing the page through your Web browser, you can refer to your machine in the URL by using one of three different methods. 

  1. "localhost"-- example --: http://localhost/ 
  2. 127.0.0.1 -- example -- http://127.0.0.1/
  3. computer name --example-- http://S-012/

If IE gives you an error message that states you are working offline, click the Connect button.

As stated earlier, you use virtual directories to access ASP.NET pages through IIS. A virtual directory is a URL path that corresponds to an actual physical directory on the hard drive. Follow the directions on the bottom of page 87 to create a new virtual directory.

Enter the name of the virtual directory. I named mine SteveWeb.

Choose the physical directory where the ASP.NET files will be stored.

Set the permissions:

Permissions:

Permission Description
Read Set by default, this permission is required for any file to be accessed whether it's an HTML file or an ASP.NET file.
Run Scripts Set by default, this permission is required for an ASP.NET file to be executed on the server.
Execute Allows the user to run an ordinary executable file. This will not normally be checked.
Write Allows the user to add, modify or delete files on the server. This will not normally be checked for security reasons.
Browse Allows the user to browse all of the files in the physical directory that corresponds with the associated virtual directory. A page will appear with a linked name of every file in the physical directory. The user can click a link to execute the file. The browse page loads when the user types the name of the host followed by the virtual directory, but leaves off a file name UNLESS a default file is available for loading. Common default file names are Default.htm, Default.asp, iisstart.asp, and Default.aspx. This will not normally be selected in a production environment, but makes life easier in a development environment.

After you're finished, the virtual directory appears in the tree view. The files currently located in the directory are displayed on the right pane. You should really create a new folder for your physical directory so when you create your virtual directory the right pane is empty.

 VIRTUAL DIRECTORIES AND APPLICATIONS

You access and manage your virtual directories by clicking the plus sign next to "Default Web Site". You'll notice four different icons.

  1. Ordinary Folder--A physical subdirectory underneath a virtual directory. It is worth noting that subdirectories underneath a virtual directory's corresponding physical directory are also accessible through IIS. To compound the confusion, the folders are referred to by their physical name. So if you have a subfolder in your physical directory (c:\physdir) named physsub(c:\physdir\physsub) which corresponds with the virtual directory at http://localhost/virtualdir, then you would access the contents of the subdirectory using a combination of the virtual and physical directory structures! http://localhost/virtualdir/physsub
  2. Folders with a Globe--A distinct virtual directory
  3. Package Folders--A virtual directory that's also a Web application. Web applications share a common set of resources and run in their own separate application domain.
  4. Error icons--Indicates that the physical directory corresponding to the virtual directory is not currently accessible.

FOLDER SETTINGS

Permissions are set on a folder by folder basis. If you want an application to have different settings, you should create subfolders and apply special permissions to the subfolders. To set the options for a directory, right click on it in IIS and choose Properties.

The Virtual Directory tab is the most important. Many of the permissions here were set by the Wizard, but they can be overwritten in the properties window. You can only change a virtual directory's corresponding physical directory if you are not browsing a subfolder's properties window.

You can click the remove button to turn the Web application back into an ordinary Web folder. You can click "create" to turn an ordinary Web folder into an application.

Changes made to a virtual directory trickle down to the subdirectories. If you want to make a change that affects all applications, change a setting in the Default Web site. If you are overriding custom settings, you will be warned.

FILE MAPPINGS

Since you can run ASP and ASP.NET on the same machine using IIS, how does IIS know which technology should be used? ASP and ASP.NET use different file extensions. ASP pages use a .asp extension and asp.net pages use an .aspx extension . There are other extensions associated with both technologies. These can be viewed by clicking the configuration button on the Virtual Directory tab. The extensions associated with the .NET framework are ASP.NET extensions.

Although both technologies can run on the same machine, they do not integrate well. They cannot share session state since they run in separate application processes.

ADDING A VIRTUAL DIRECTORY TO NETWORK NEIGHBORHOOD

If you double click an ASP.NET file from Windows Explorer or My Computer, it will open the associated page editor. If you want to click on a file and execute it, you must add the virtual directory to Network Neighborhood.

  1. Open Windows Explorer
  2. Click on Network
  3. Double Click on Add Network Place
  4. Complete the Add Network Place Wizard.

INSTALLING ASP.NET

There are three different ways to install ASP.NET

  1. Download the free .NET redistributable.
  2. Install Visual Studio.NET
  3. ASP.NET Web Matrix
  4. ASP.NET Premium Edition ( I couldn't find this at Microsoft's site)

If you receive a message that you are missing Microsoft Data Access Components, stop the installation and download the latest version of MDAC.

MIGRATING FROM ASP

Migrating ASP pages to ASP.NET is not easy. There are three ways you can cope with this issue:

  1. Run ASP applications alongside ASP.NET--Gradually replace your ASP pages as you learn ASP.NET. However, during the transition, state information cannot be shared. To make matters worse, ASP or ASP.NET sessions can time out while visitors are viewing pages related to the opposite technology. This option is best if your site doesn't rely on state management and is mostly content driven.
  2. Replace ASP pages with similar ASP.NET pages--This approach allows state information to be shared, but doesn't take advantage of ASP.NET's benefits.
  3. Replace ASP pages with redesigned ASP.NET pages. --This is the ideal solution but is the most time consuming and costly. Pages that use Response.Write statements must be completely redesigned to take advantage of ASP.NET's event driven model. It might be easier to start an application from scratch rather than migrate it over from classic ASP.