Article
Build Your Own ASP.NET Website Using C# And VB.NET, Chapter 1 - Introduction to .NET and ASP.NET
Installing Internet Information Services (IIS)
Do you need to install IIS locally even if the final site will not be hosted locally? The answer is: yes. Even if you're uploading your Web applications via FTP to your Web host, installing IIS allows you to view, debug, and configure your applications locally before deployment.
IIS comes with most versions of server-capable Windows operating systems, including Windows 2000 Professional, Server, and Advanced Server, Windows XP Professional, and Windows Server 2003, but it's not installed automatically in all versions, which is why it may not be present on your computer. To see whether you have IIS installed and running, simply navigate to your Administrative Tools menu and check to see if Internet Information Services is an option. Users of Windows 2000 Professional will find the Administrative Tools in their Control Panels, while XP and Server family users also have shortcuts in their start menus.
If the shortcut is not visible, then you don't have it installed. To install IIS, simply follow these steps:
- In the Control Panel, select Add or Remove Programs.
- Choose Add/Remove Windows Components. The list of components will become visible within a few seconds.
- In the list of components, check Internet Information Services (IIS).
- Click Next. Windows prompts you to insert the Windows CD and installs IIS.
Once IIS is installed, close the Add or Remove Programs dialog. You can check that IIS has installed correctly by seeing if you can find it within the Administrative Tools menu. If you can, it's installed.
You are now ready to begin hosting Web applications. Although we won't cover the configuration of IIS for external use, I will show you how to configure IIS to support local development of ASP.NET applications in order that they may be uploaded to your external Web hosting provider later.
Installing Internet Explorer
As a Windows user, you have Internet Explorer installed by default, but I recommend you run at least version 5.5. You can check your version by selecting About Internet Explorer from the Help menu.
If your version of Internet Explorer is earlier than 5.5, you can download the latest version (version 6 SP1 as of this writing) for free from the Internet Explorer Website. Remember, although ASP.NET will work with older versions of IE, certain ASP.NET functionality works best with the latest version.
The Internet Explorer Website does not allow you to install a version of your choice; it permits you to download only the most recent version that's available. Because the newest versions of Internet Explorer will include the latest patches, it's a good idea to stick with what they give you.
Installing the .NET Framework and SDK
To begin creating ASP.NET applications, you'll need to install the .NET Framework and SDK. The .NET Framework includes the necessary files to run and view ASP.NET pages, while the .NET Framework SDK includes samples, documentation, and a variety of free tools.
The .NET Framework SDK also provides you with the ability to install MSDE, the free database server that you can use with this book. Once the .NET Framework and SDK are installed, little else needs to be done for you to begin working with ASP.NET. The .NET Framework is installed as part of the operating system if you're lucky enough to be running Windows .NET Server 2003, in which case you can skip directly to installing the SDK. If not, you will need to download the .NET redistributable package, which is approximately 21 MB, and includes the files necessary for running ASP.NET applications.
To develop .NET applications, you also need to install the software development kit, which includes necessary tools along with samples and documentation. Be aware that the .NET Framework SDK is 108 MB in size�be prepared to wait!
Warning
Installing the .NET Framework before you install IIS will prevent your applications from working correctly.
Download and Install the Redistributable
The best method of acquiring the .NET Framework is to download and install it directly from the Web. To accomplish this, simply follow the steps outlined below:
- Go to the ASP.NET support site at http://www.asp.net/ and click the Download link.
- Click the Download .NET Framework Redist Now link. Remember, we will install the redistributable first, then we will install the SDK. The link will advance you to a download page.
- Choose the language version of the install you want, and click Download.
- When prompted, save the file to a local directory by choosing Save.
- After the download is complete, double-click the executable to begin the installation.
- Follow the steps presented by the .NET Setup Wizard until installation completes.
Download and Install the SDK
Now that you've installed the redistributable, you need to install the software development kit (SDK):
- Go to the ASP.NET support site at http://www.asp.net/ and click the Download link.
- Click the Download .NET Framework SDK Now link. The link will advance you to a download page.
- Choose the language version of the install you want to use and click Download, as you did to download the redistributable.
- When prompted to do so, save the file to a local directory by choosing Save.
- After the download is complete, double-click the executable to begin the installation. Before you do, I strongly recommend closing all other programs to ensure the install proceeds smoothly.
- Follow the steps outlined by the .NET Setup Wizard until installation completes./#eli#
The SDK will take slightly longer to install than the redistributable. Once it's finished, check to see if it exists in your programs menu; navigate to Start > Programs > Microsoft .NET Framework SDK.
Configuring IIS
Although little configuration needs to be done before you begin working with IIS, I'll use this section to introduce some basic features and functionality within IIS:
- Determining whether ASP.NET installed correctly
- Determining where files are located on the Web server
- Using localhost
- How to start and stop the Web server
- How to create a new virtual directory and modify its properties
Determining whether ASP.NET Installed Correctly
Once IIS is installed on your computer, you can open it by selecting Internet Information Services from the Administrative Tools menu. The first task is to make sure that ASP.NET was integrated into IIS when you installed the .NET Framework. Although, logically, ASP.NET should install automatically because it's a component of the .NET Framework, sometimes it doesn't. Don't let this alarm you�it's a common occurrence and is addressed in the Microsoft Knowledge Base. You can determine whether IIS was installed correctly by following these steps:
- Open IIS, if you haven't already done so, and click on the + symbol next to your computer's name.
- Right-click Default Web Site and select Properties.
- Navigate to the Documents tab. If default.aspx appears within the list, ASP.NET was installed correctly.
Another way to check whether ASP.NET installed correctly is by following these steps:
- Navigate to the Application Mappings menu by right-clicking the root Website node (your computer's name) and choosing Properties.
- Select the Home Directory tab, and choose Configuration.
- The Application Mappings menu displays all of the extensions and their associated ISAPI Extension DLLs, as we see in Figure 1.2.

Figure 1.2. If the .aspx ISAPI Extension DLL appears within the Application Mappings menu, then ASP.NET was installed correctly.
Since I can imagine you're dying to know what an ISAPI Extension DLL is, let me explain. You may know that a DLL is a Dynamically Linked Library, which is essentially a self-contained code module that any number of applications can draw on. When a Web server hosts a dynamic Website, page requests must be processed by program code running on the server before the resultant HTML can be sent back to the requesting browser (the client). Now, as was the case with traditional ASP, ASP.NET performs this processing with the help of its Internet Server Application Programming Interface (ISAPI) extension DLL. ISAPI allows Web requests to be processed through the Web server by a DLL, rather than an EXE, as is the case with Common Gateway Interface (CGI) pages. This approach is advantageous because DLLs are much more efficient, and require far less resources and memory than executables. IIS uses the file extension of a requested page to determine which DLL should process the request according to the mappings shown in the screenshot above. So, we can see that pages ending in .aspx, .asmx, or .ascx, among others, will now be passed by IIS to the ASP.NET DLL (aspnet_isapi.dll) for processing. OK, enough of the tech-talk. Let's get back to it!
If you've come to the conclusion that ASP.NET was not installed on your computer, you'll have to install it manually from the command prompt:
- Open the command prompt by selecting Start > Run, type CMD, and select OK.
- Type the following command (all on one line) to install ASP.NET on Windows 2000 Professional, Server, or Advanced Server:
C:\WINNT\Microsoft.NET\Framework\ver\aspnet_regiis.exe -iOr on Windows XP Professional:
C:\WINDOWS\Microsoft.NET\Framework\ver\aspnet_regiis.exe -iIn these commands,
veris the directory corresponding to the version of the .NET Framework you have installed. - Once ASP.NET is installed, close the command prompt and check again to confirm whether ASP.NET installed correctly.
If it still hasn't installed, try visiting the Microsoft Knowledge Base for help.
Where Do I Put My Files?
Now that you have ASP.NET up and running, let's take a look at where the files for your Web applications are kept on the computer. You can readily set IIS to look for Web applications within any folder of your choice, including the My Documents folder or even a network share. By default, IIS maps the wwwroot subfolder of C:\Inetpub on the server to your Website's root directory, and it is generally considered a good repository for storing and managing your Web applications.
If you open this wwwroot folder in Windows Explorer, and compare it with the folder tree that appears on the left of the IIS console, you'll notice that the folders in Explorer also appear under your Default Web Site node. Note that, while several of these folders have the regular Explorer folder icon in the IIS view, others have a special Web application icon, indicating that these folders contain the pages and other items for a particular Web application. These special folders are what IIS calls Virtual Directories, and, in fact, they do not have to share the name of the physical folder to which they map. We'll see more on this shortly.