Setting Up Internet Information Services and ASP.NET
(Page 1 of 5 )
This article will explain how to install ASP.NET, configure Internet Information Services, (IIS), and create virtual directories. It is excerpted from chapter two of the book
The Definitive Guide to SAMBA 3, written by Roderick Smith (Apress, 2004; ISBN: 1590592778).
THE LAST CHAPTER GAVE a sweeping introduction to the .NET Framework. But before you start creating ASP.NET web pages and applications, you need to make sure that you have the correct environment on your computer.
In other words, before you dive into the theory and concepts of ASP.NET in any more detail, it’s time to take care of a few easier tasks. In this chapter, you’ll walk through the process of installing ASP.NET, configuring Internet Information Services (IIS), and creating virtual directories. These tasks are supported by wizards or graphical tools, so they don’t require the same level of expertise as actual ASP.NET programming.
Web Servers and You Web servers run special software to support mail exchange, FTP and HTTP access, and everything else clients need in order to access web content. In the Microsoft Windows operating system, the built-in IIS component plays this role, allowing any computer to become a web server.
In most cases, you won’t be developing on the same computer that you use to host your website. If you were, you would hamper the performance of your web server by tying it up with development work. You would also frustrate clients if a buggy test application crashes the computer and leaves the website unavailable, or if you accidentally overwrite the deployed web application with a work in progress! Generally, you’ll perfect your web application on another computer, and then copy all the files to the web server. This process of deployment is described in Chapter 12.
However, in order to use ASP.NET, your computer needs to act like a web server. In fact, while you’re testing an ASP.NET application your development computer will work in exactly the same way as it would over an Internet connection to a remote client. When you test a page, you’ll actually request it through IIS, and receive the rendered HTML over an HTTP channel. The only difference between the way your computer works while testing the website and the way a web server behaves when the application is deployed is that your computer won’t be visible and accessible to remote clients on the Internet.
This configuration allows you to perfect your security model and perform realistic testing on your development computer. The drawback is that you need to have the IIS web hosting software on your computer in order to test an ASP.NET website. IIS is included with Windows 2000, Windows XP, and Windows 2003 Server, but it’s an optional component and it isn’t installed by default. To create ASP.NET programs successfully, you need to make sure IIS is installed before you install the .NET Framework or Visual Studio .NET.
Installing Internet Information Services Installing IIS is easy. Here are the steps you follow on a Windows 2000 or Windows XP computer:
- Click Start, and select Settings -> Control Panel.
- Choose Add or Remove Programs.
- Click Add/Remove Windows Components.
- If Internet Information Services is checked (see Figure 2-1), you already have this component installed. Otherwise, click it and click Next to install the required IIS files. You’ll probably need to have your Windows setup CD handy.
Figure 2-1. Installing Internet Information Services
If you’re using Windows Server 2003, you can install IIS through the Add/Remove Windows Components dialog box, but it’s more likely that you’ll use the Manage Your Server wizard. Choose Add or Remove a Role when you start the wizard, and follow all the instructions. Choose the Web application server role to install IIS and the ASP.NET engine in one operation.
When IIS is installed, it automatically creates a directory named c:\Inetpub\wwwroot, which represents your website. Any files in this directory will appear as though they’re in the root of your web server.
To test that IIS is installed correctly and running, browse to the c:\Inetpub\wwwroot directory and verify that it contains a file called localstart.asp. This is a simple ASP (not ASP.NET) file that is automatically installed with IIS. If you try to double-click this file to run it from the local directory, you’ll receive an error message informing you that your computer doesn’t know how to handle direct requests for ASP files (see Figure 2-2) or another program such as Microsoft FrontPage will try to open it for editing.

Figure 2-2. Attempting to open an ASP file through Windows Explorer
This limitation exists because of the way that ASP and ASP.NET files are processed. In a typical web scenario, IIS receives a request for a file. It then looks at the file extension and uses that to determine if the file should be allowed, and what program (if any) is required to handle it. Ordinary HTML files will be sent directly to your browser. ASP files, however, will be processed by the ASP service, which IIS will start automatically. The ASP service loads the requested file, runs the code it contains, and then creates the final HTML document, which it passes back to IIS. IIS then sends the HTML document to the client. The whole process, which is diagrammed in Figure 2-3, is quite similar to how ASP.NET files are processed, as you’ll see later.

Figure 2-3. How IIS handles an ASP file request
In order to test that IIS is working correctly, you need to request the localstart.asp file through IIS, over the standard HTTP channel. You can do this using an Internet browser. Just open an application like Internet Explorer, and type a request for the file using the name of your computer. For example, if your computer’s name is devtest, you would type http://devtest/localstart.asp. IIS will receive your request, ASP will process the file, and you’ll receive a generic introductory page in your browser (see Figure 2-4).
If you don’t know the name of your computer, right-click the My Computer icon either on your desktop or in Windows Explorer, and select Properties. Then, choose the Computer Name tab. The computer name is next to the heading “Full computer name.” Alternatively, you can save some effort by using one of two presets that automatically refer to the local computer, whatever its name. These are the “loopback” address 127.0.0.1, and the alias localhost. That means you can try entering http://localhost/localstart.asp or http://127.0.0.1/localstart.asp on any computer to test if IIS is installed.

Figure 2-4. Requesting an ASP file through IIS
What If I Can’t Connect?If you try the previous steps, but receive an “Unable to connect” message, you may need to investigate further. Your first step is to check that IIS is installed correctly and enabled. To check this, you need to use a utility called IIS Manager by selecting Settings -> Control Panel -> Administrative Tools -> Internet Services Manager from the Start menu. You should see your computer listed under the Internet Information Services node in the tree. Expand this node, and click on the Websites folder. In the list on the right, it should indicate that your computer’s default website is running, as shown in Figure 2-5. If not, try right-clicking the icon that represents your computer and choose to restart IIS.

Figure 2-5. The default website is currently running
Lastly, you may need to tweak your Internet settings. For this task, choose Settings -> Control Panel -> Internet Options from the Start menu. Then choose the Connections tab. If you’re working on a local network and have special proxy server settings applied, verify that they don’t conflict with your computer by clicking the LAN Settings button.
If you connect to the Internet using a connection that isn’t always present (such as a modem that connects over a telephone line), you may receive an error message that informs you that a local page cannot be loaded because you’re currently working offline. In this case, just click Connect, and the page will appear successfully without you needing to actually connect to the Internet. To prevent this message from appearing, you can select Never Dial A Connection from the Connections tab, although this will not always stop the problem from reoccurring. If you’re prevented from performing another operation (such as creating a web project in Visual Studio .NET) because the operating system believes you’re offline, simply enter http://localhost/localstart.asp in a browser, and then click Connect when you’re prompted to go online.
Next: Managing Websites >>
More ASP.NET Articles
More By Apress Publishing
|
This article is excerpted from chapter two of the book The Definitive Guide to SAMBA 3, written by Roderick Smith (Apress, 2004; ISBN: 1590592778). Check it out at your favorite bookstore today. Buy this book now.
|
|