How to Test and Debug an ASP.NET 2.0 Application - How to test a file-system web site with IIS
(Page 5 of 5 )
When you run a file-system web site, it runs under the ASP.NET Development Server by default. Because this server has limitations, however, you’ll want to be sure to test a file-system web site under IIS as well as under the development server. Figure 4-6 describes how you do that.
To start, you need to create a virtual directory for the web site as described in figure 4-1. Then, if you open the web site from this virtual directory, it will automatically run under IIS. Alternatively, you can open the file-system web site directly and change its start options so the URL you specify is used to start the application. In this figure, for example, you can see that the Use Custom Server option has been selected and the URL for the web site’s virtual directory has been entered in the Base URL text box.
This figure also lists the limitations of the ASP.NET Development Server. The most significant of these limitations is that it always runs under the current user’s security context, but your own user account probably has stronger security privileges than the account IIS runs ASP.NET applications under. As a result, when you move the application to a production web server, you may have to contend with security issues that weren’t apparent when you tested with the development server, especially if you access files or databases located in folders outside of the application’s folder structure.
The dialog box for specifying a web server

Figure 4-6. How to test a file-system web site with IIS
How to test a file-system web site with IIS
- Create a virtual directory for the web site as described in figure 4-1.
- Open the web site from its virtual directory, or open the file-system web site and then use the Property Pages dialog box shown above to specify the URL for the virtual directory.
- Run the application using one of the techniques in figure 4-4.
Limitations of the ASP.NET Development Server
- Can serve pages only to the local computer.
- Runs in current user’s security context, so it doesn’t accurately test security issues.
- Does not include an SMTP server, so it can’t be used to test email applications.
- Uses a randomly chosen port rather than the standard HTTP port 80.
Description
- By default, a file-system web site is run using the ASP.NET Development Server. To run a file-system web site using IIS, you can use one of the techniques above.
- To open the Property Pages dialog box, right-click the project in the Solution Explorer and select Property Pages from the shortcut menu. Then, to change the server that’s used to run the web site, click the Start Options node, select the Use Custom Server option, and enter the URL of the virtual directory for the web site.
How to test an application from outside of Visual Studio
Once you’ve thoroughly tested and debugged an application from within Visual Studio, you’ll want to run it from outside of Visual Studio to make sure it works properly. Figure 4-7 describes how you do that.
To start, you open the browser you want to use. In this example, I used Mozilla Firefox. Then, you enter the URL for the starting page of the application and press Enter. When you do, a request for the page is sent to the server and the resulting page is displayed in the browser.
Note that to run a local IIS web site, you use “localhost” in the URL to identify the server. The URL in this figure, for example, refers to the Order.aspx page of the Ch03Cart web site. This web site is located in the ASPNET2005 directory of the local IIS server. In contrast, to run a remote IIS web site, you specify the actual server name in the URL like this:
http://mma1/ASPNET2005/Ch03Cart/ Order.aspx
And to run an FTP web site, you enter the browse location like this:
http://Murach/Ch03Cart/Order.aspx
If you haven’t already tested an application from within Visual Studio in each browser that might be used to run the application, you should do that from outside Visual Studio. In addition, if the application retrieves and updates data in a database, you’ll want to test it simultaneously in two browser windows. To understand why, you need to realize that after an application retrieves data from a database, it closes the connection to the database. Because of that, two or more users can retrieve the same data at the same time. This is called concurrency, and it can cause concurrency errors when the data is updated.
In section 3 of this book, you’ll learn more about concurrency and how you avoid concurrency errors. For now, you should just realize that you’ll need to test your applications to be sure that they handle concurrency problems.
The Order page displayed in a Mozilla Firefox browser outside of Visual Studio

Figure 4-7. How to test an application from outside of Visual Studio
Description
- You can run any IIS application from outside of Visual Studio. To do that, open the browser you want to use, enter the URL for the starting page of the application as shown above, and press Enter.
- When you run an application from outside of Visual Studio, you can run it in two or more browser windows simultaneously. That way, you can be sure that the application provides for any concurrency errors that can occur.
- If you want to use the debugger while testing for concurrency errors, you can run one instance of the application from within Visual Studio with debugging, and you can run another instance from outside of Visual Studio.