Bagikan melalui


How to: Test Web Pages in Visual Web Developer

While creating pages and Web sites in Visual Web Developer, you can run pages to test them. For more information, see Testing Web Pages in Visual Web Developer.

To run a Web page in order to test it

  • Perform one of the actions listed in the following table. All of the actions run the specified page in the default browser.

    To

    Do this

    Run the current page or startup page in the debugger. For information about the startup page, see How to: Specify Start Pages for Testing Web Sites in Visual Web Developer.

    On the Debug menu, click Start, or press F5.

    If the page or the Web site has not previously been configured to enable debugging, Visual Studio prompts you to enable debugging. If you choose not to enable debugging, the page runs in the default browser but does not allow you to attach a debugger to it.

    NoteNote:
    Before publishing a Web site, you should disable debugging because it adds overhead to performance and in the event of an error might display information to the user that you do not want to show. For details, see How to: Enable Debugging for ASP.NET Applications

    Run the current page or startup page without the debugger. For information about the startup page, see How to: Specify Start Pages for Testing Web Sites in Visual Web Developer.

    On the Debug menu, click Start Without Debugging, or press CTRL+F5.

    Run the current page in a browser instance inside of Visual Studio.

    Right-click a blank area of the page and then click View in Browser.

    NoteNote:
    The View in Browser command is not available for files that do not render in a browser (such as the Web.config file).

Testing with an Alternate Browser

When you run a page, Visual Studio invokes the current default browser. You can also test a page using an alternate browser, as described in the following procedure.

To test a Web page with an alternate browser

  1. In Solution Explorer, right-click the page you that want to test and then click Browse With.

  2. In the Browse With dialog box, select an alternate browser.

  3. If the browser that you want to use is not listed, click Add, type the name of or browse to the alternate browser program, and then click OK.

    Note

    You can set the alternate browser as the default browser for Visual Studio by clicking Set as Default. This sets the default browser only for testing Web pages in the current Web site. It does not affect the default browser setting in Windows.

  4. When you have selected a browser, click Browse.

Setting Build Options for Testing a Page

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

To specify build behavior when running a page

  1. In Solution Explorer, right-click the name of the Web site that you want to run, and then click Property Pages.

  2. Click the Build tab.

  3. In the Before running the startup page list, select the build option that you want before running pages.

If you have configured the Web site to build before running a page, you can further specify what happens if the page or Web site has errors.

To specify run behavior if build errors occur

  1. On the Tools menu, click Options.

  2. Select the Show all settings check box if it is not already selected.

  3. Expand the Projects and Solutions node, and then click Build and Run.

  4. Under On Run, when build or deployment errors occur, select the option for behavior that you want if the build process encounters an error.

See Also

Tasks

How to: Specify Start Pages for Testing Web Sites in Visual Web Developer

Concepts

Testing Web Pages in Visual Web Developer

Building Web Sites