Partager via


Testing Web Pages in Visual Web Developer

Visual Web Developer provides you with a variety of ways to test Web pages as you are developing them. You have the following choices:

  • Run the Web site with debugging   This option runs the Web site in the browser and allows you to perform ordinary debugging tasks such as stepping through code and stopping at breakpoints.

  • Run the Web site without debugging   This option runs the Web site in the browser without using the debugger. It approximates the experience that the user will have.

  • View individual pages in a browser   This option runs a selected page in the browser. Debugging breakpoints are not in effect even if debugging is enabled.

Browser Options

By default, Visual Studio 2005 uses Internet Explorer 6 to test pages in all of the above situations. If you want to test pages using a different browser, you can right-click the page in Solution Explorer and then click Browse With. A dialog box opens where you can select a browser from the Browsers list, add new browsers to the list, and set the one you select as the default browser. The default browser will then be used when you choose to run the Web site with or without debugging, or to view an individual file in the browser.

Build Options

By default, Visual Web Developer builds the Web site when you run a page. This helps you find compile-time errors before the page is displayed in the browser. You can set options to specify whether you want to build the entire site, the current page, or not build at all.

For more information, see How to: Test Web Pages in Visual Web Developer and Building Web Sites.

Running with a Startup Page

By default, when you run a Web site, Visual Web Developer runs the page that is currently open. However, in some cases you might always want to start your Web site with a specific page. For example, your Web site might have a home page where users make a selection that is required for other pages in the site. In this case, you can configure your Web site to first display the home page when you test so that you begin at the correct point in the application. Setting a start page also allows you to specify what Visual Web Developer should do if you run a non-executable page such as Web.config.

To specify a start page, right-click the page in Solution Explorer and then click Set As Start Page.

Note

Setting a start page in Visual Web Developer affects only your testing. It does not set the start page for the Web site when it is published. To specify a default page for your Web site, use Internet Information Services (IIS) Manager to enable a default document in a Web site or virtual directory, and then select the page that you want. For more information, see the topic "Setting Up Default Documents" in the IIS Operations Guide.

Running on a Specific Web Server

When you run a page, Visual Web Developer launches the Web server, launches the browser, and loads the specified page into the browser. In effect, Visual Web Developer passes the URL of the current page to the Web server and runs the page as if it had been requested using that URL.

The Web server that is used to run the page depends on the type of Web site you are working with:

  • For File system Web sites, Visual Web Developer launches its own Web server and runs the page locally. However, you can also specify a start URL that indicates the URL to use when testing a Web page. This is useful if the file system Web site is on another computer — for example, if you are accessing the site using a mapped drive — and you want to test the page using IIS on the other computer. For more information about the ASP.NET Development Server, see Web Servers in Visual Web Developer.

  • For local IIS and remote IIS sites, Visual Web Developer runs the page in the corresponding instance of IIS. For example, for a local IIS site, the page runs in your local copy of IIS. For more information, see Web Servers in Visual Web Developer.

  • For FTP-deployed Web sites, Visual Web Developer runs the page using the start URL that you provide as part of the FTP Web site properties. If you have not provided one, Visual Web Developer prompts you for the start URL when it is required. For more information, see FTP-Deployed Web Sites.

In the case of a remote Web site or an FTP site, the remote computer must be running the .NET Framework version 2.0, because the page is running in the context of the remote server.

Running with the Debugger

Running your page with the debugger enables you to perform ordinary debugging tasks, such as stepping through code and stopping at breakpoints. For more information, see ASP.NET Debugging Overview.

Running with the debugger requires the following:

  • The page or Web site must be configured to enable debugging, which causes the page to be compiled with extra information (debugging symbols) that the debugger requires. Visual Web Developer checks to see if debugging is enabled, and if not, it sets the compilation options in the local Web.config file to include debugging, creating the Web.config file if necessary.

  • The Web server must be configured with adequate permissions to allow the current user account to debug. If you are debugging a page running under IIS 6.0, you must be an administrator on the computer. If that is not practical, you can use the ASP.NET Development Server to debug applications without special permissions. For details, see Web Servers in Visual Web Developer and How to: Specify the Web Server for Web Sites.

If these conditions cannot be met, you can run the page in Visual Web Developer without enabling debugging.

Note

You should configure your pages or Web site to run without debugging before you deploy the site to a production server. Debugging options add overhead to the page and can affect server performance.

See Also

Tasks

How to: Test Web Pages in Visual Web Developer