Tuesday, September 17, 2024

ASP.NET: Testing a file-system web site with IIS

This article is an excerpt from the book: Murach’s ASP.NET 2.0 Web Programming with C# 2005.

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

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.

Add to Del.icio.us | Digg | Yahoo! My Web | Furl

Bookmark Murdok:

Joel Murach has been writing and editing for more than 10 years. During that time, he sharpened his programming skills as a contract programmer in San Francisco and his instructional skills as a trainer for HarperCollins Publishing. He always brings a vision to his projects that leads to improved effectiveness for his readers.

Related Articles

5 COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles

Download new year blues.