Chapter 27. Using the ASP.NET Development Server

<feature><title>In this chapter</title> </feature>

Introduction to the ASP.NET Development Server

If you’ve ever read comments or blogs from the ASP.NET development team at Microsoft, you can’t help but realize how excited they are about ASP.NET 2.0. As you’ll see when reading the chapters in this section, there’s plenty to be excited about. Because you can do so much in ASP.NET 2.0 without writing any code at all, many Web developers who have historically not taken advantage of Web programming technologies will likely find a use for many of the features offered by ASP.NET 2.0.

Some of the things that you can do using ASP.NET 2.0 are:

  • Display data from a database on a Web page.

  • Allow people to create accounts and log in to your Web site.

  • Add robust form validation to your Web forms.

  • Add dynamic Web site navigation.

The likelihood of so many people delving into ASP.NET does present problems. Because ASP.NET is a server technology, it requires a Web server to run. The following Windows editions do not ship with a Web server:

  • Windows Vista Starter

  • Windows Vista Home Basic

  • Windows Vista Home Premium

  • Windows XP Home Edition

If you’re using one of these operating systems, the ASP.NET Development Server provides you with the capability of developing and testing ASP.NET applications.

Another problem that widespread use of ASP.NET may introduce is one that is more likely to occur in educational environments. Developing with ASP.NET against a Web server has traditionally required a user to have administrative access to the machine. Many educational institutions don’t allow users to be administrators. Therefore, this would result in developers not being able to debug applications, and in the worst-case scenarios, they would not be able to run ASP.NET applications at all.

For more information on ASP.NET debugging, see “Using Expression Web with Visual Web Developer Express Edition,” p. 655 (Appendix A).

Both of these problems are nicely solved with the ASP.NET Development Server that is provided with Expression Web. The ASP.NET Development Server fully supports ASP.NET 2.0 and allows for the development of ASP.NET applications on all current Microsoft operating systems and by non-administrators as well.

Note

In order to use ASP.NET 2.0, you’ll also need the .NET Framework 2.0. It’s included in Windows Vista. If you use Windows XP or Windows 2000, you can download the 32-bit .NET Framework from http://www.microsoft.com/downloads/details.aspx?FamilyID=0856eacb-4362-4b0d-8edd-aab15c5e04f5&displaylang=en. The 64-bit version can be found at http://www.microsoft.com/downloads/details.aspx?familyid=B44A0000-ACF8-4FA1-AFFB-40E78D788B00&displaylang=en.

Those URLs are both plenty long. If you’d prefer, go to http://download.microsoft.com and search for “.NET Framework 2.0”. You will easily find the .NET Framework.

How to Use the ASP.NET Development Server

When you create a Web site in Expression Web, you have many options from which to choose, but the easiest to work with is a disk-based Web site. However, because a disk-based Web site doesn’t actually reside on a Web server, it doesn’t sit on top of a platform that supports server-side technologies like ASP.NET. That’s where the ASP.NET Development Server comes into the picture. The ASP.NET Development Server is used by default for all ASP.NET pages browsed from a disk-based Web site.

Note

The ASP.NET Development Server is only supported on disk-based Web sites.

For more information on creating Web sites in Expression Web, see “Creating a Web Site”, p. 25 (Chapter 2).

Expression Web starts the ASP.NET Development Server on a random port (shown in Figure 27.1) when an ASP.NET page is previewed in your browser.

The ASP.NET Development Server is started for you automatically when you preview an ASP.NET page from a disk-based Web site.

Figure 27.1. The ASP.NET Development Server is started for you automatically when you preview an ASP.NET page from a disk-based Web site.

Tip

The first time you browse an ASP.NET page from a disk-based Web site, Expression Web will automatically install the ASP.NET Development Server if it is not already installed. Port numbers are used whenever communication takes place over the Internet. By

Note

default, Web servers use port 80 for HTTP traffic. There are other default ports for other services.

The ASP.NET Development Server chooses a random port in a port range that is not used by common services. This prevents the port that the ASP.NET Development Server uses from conflicting with something else running on your computer.

If you choose, you can also use the ASP.NET Development Server for non-ASP.NET pages. To configure whether the ASP.NET Development Server is used only for ASP.NET pages or for all content, click Site, Site Settings and then click the Preview tab. As shown in Figure 27.2, two options are available for previewing with the ASP.NET Development Server:

  • For Only ASP.NET Web Pages—When this option is selected, Expression Web will launch the ASP.NET Development Server when .aspx files are previewed. If non-ASP.NET pages are previewed, Expression Web will use the path of the Web site that is open.

  • For All Web Pages—When this option is selected, Expression Web will use the ASP.NET Development Server for all files that are previewed.

Configuring use of the ASP.NET Development Server is performed through the Site Settings dialog.

Figure 27.2. Configuring use of the ASP.NET Development Server is performed through the Site Settings dialog.

If you attempt to preview an ASP.NET page using a disk path, Expression Web will warn you that it won’t display ASP.NET content. You’ll need to use a Web server (like the ASP.NET Development Server) to see this content.

Figure 27.3. If you attempt to preview an ASP.NET page using a disk path, Expression Web will warn you that it won’t display ASP.NET content. You’ll need to use a Web server (like the ASP.NET Development Server) to see this content.

Note

If you attempt to preview an ASP.NET page using a disk path, Expression Web will warn you that it won’t display ASP.NET content. You’ll need to use a Web server (like the ASP.NET Development Server) to see this content.

If you get a message warning you that dynamic content exists on the page even though you have the ASP.NET Development Server enabled, see “Dynamic Content Warning with ASP.NET Development Server” in the “Troubleshooting” section of this chapter.

The ASP.NET Development Server will remain running for as long as Expression Web is running. However, it is possible to stop it if you wish. Examples of reasons why you might want to manually stop the ASP.NET Development Server include:

  • You have an ASP.NET that caches information and you want to clear the cache so that can test a particular scenario.

  • You are testing code in your ASP.NET application that runs when your application first loads.

To manually stop the ASP.NET Development Server, right-click on the icon in the system tray shown previously in Figure 27.1 and choose Stop from the menu. Alternatively, you can choose Show Details from the menu and click the Stop button, as shown in Figure 27.4. Either way, the ASP.NET Development Server will stop immediately and will be launched again on a new port the next time it’s needed.

The ASP.NET Development Server can be stopped from the Details dialog box. You can also click the provided link to browse the Web site in your Web browser.

Figure 27.4. The ASP.NET Development Server can be stopped from the Details dialog box. You can also click the provided link to browse the Web site in your Web browser.

Note

If the ASP.NET Development Server is running when you exit Expression Web, it will be stopped automatically.

Limitations of the ASP.NET Development Server

The ASP.NET Development Server solves a lot of problems. In addition to providing a solid development platform for ASP.NET for those using versions of Windows without a Web server, it also allows non-administrators the option of debugging locally. However, even with those benefits, there are some limitations.

Process Identity

There are occasions in an ASP.NET application where you may need to run code under a specific user’s identity. For example, suppose you have an ASP.NET application that makes heavy use of a Microsoft SQL Server database and you want that database to be accessed via a particular user account. Being able to configure ASP.NET to always run under that particular user account is a valuable feature.

On a production Web server, ASP.NET applications run inside either the aspnet_wp.exe process (IIS 5 and IIS 5.1) or the w3wp.exe process (IIS 6 and IIS 7). These processes have many configuration options, including the ability to configure the identity under which they run. The ASP.NET Development Server always runs under the user who is logged onto the computer. You cannot configure it to run under a different user account.

No Remote Access

The ASP.NET Development Server is designed to be browsed from the local machine only. That means that you can only browse it using localhost or the TCP/IP loopback address, 127.0.0.1. Using either a machine name or machine IP address will result in an error page in the browser.

Because only localhost and 127.0.0.1 are acceptable to the ASP.NET Development Server, you cannot browse an ASP.NET Web site running on the ASP.NET Development Server from a remote machine. If you need that functionality, you will need to use IIS to develop your ASP.NET application.

Tip

Even though you can’t browse the ASP.NET Development Server remotely, you can use the ASP.NET Development Server to develop against content that’s located on a different machine. You’ll need to map a drive to the remote content and then start the ASP.NET Development Server from a command line using a switch to point it to the content.

For more information on starting the ASP.NET Development Server from a command prompt, see “Lagniappe: Starting the ASP.NET Development Server from the Command Prompt” later in this chapter.

No Support for ASP Pages

Even though you can configure the ASP.NET Development Server to serve all Web pages, as shown previously in Figure 27.2, it is explicitly designed to not allow ASP pages. If you attempt to browse to an ASP page in the ASP.NET Development Server, you’ll get an error telling you that ASP pages are not served, as shown in Figure 27.5.

The ASP.NET Development Server does not serve ASP pages. Only ASP.NET and HTML pages are supported.

Figure 27.5. The ASP.NET Development Server does not serve ASP pages. Only ASP.NET and HTML pages are supported.

Note

You might wonder why the ASP.NET Development Server doesn’t support ASP pages. There really isn’t any technical reason. It was simply a design choice made by Microsoft, most likely because the ASP.NET Development Server was first developed as a Web server specifically for ASP.NET development tools.

Troubleshooting

Dynamic Content Warning with ASP.NET Development Server

I have my Web site configured to use the ASP.NET Development Server, but when I browse an ASP.NET page, I get the warning that the page contains dynamic content and the page is still served from the disk path. How can I correct this problem?

In my testing, there were several occasions when I had the ASP.NET Development Server configured to launch when browsing ASP.NET pages, but for some reason, Expression Web would launch pages from the file path on the first attempt. When that happens, simply close the browser and preview the page again and it should work correctly.

Lagniappe (lan yap’) n., a gift or bonus: Starting the ASP.NET Development Server from the Command Prompt

In most scenarios, launching the ASP.NET Development Server from within Expression Web will suffice. However, if you want to author against remote content via a mapped drive, you’ll need to take a different approach and launch the ASP.NET Development Server from a command prompt.

To launch the ASP.NET Development Server from a command prompt, navigate to the %windir%Microsoft.NETFrameworkv2.0.50727 directory and then run the following command:

webdev.webserver /port:<port> /path:<path>

You’ll need to replace <port> with the port number of your choice and <path> with the path to the mapped drive. For example, to launch the ASP.NET Development Server on port 9000 and browse content located at z:website, you would use the following:

webdev.webserver /port:9000 /path:z:website

You will then be able to browse your content on the port specified.

Adding on to the preceding example, to browse a page called form.aspx, you would enter the following into your Web browser:

http://localhost:9000/form.aspx
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.149.214.32