共用方式為


Web Site Administration Tool Application Tab

Use the Application tab of the Web Site Administration Tool (Web Site Administration Tool) to manage commonly used settings related to the Web application and site.

Use the Application tab to manage the following:

  • Application settings name/value pairs.

    Application settings are name/value pairs that represent configurable values text in the Web application. Use application settings to store custom application configuration information, such as file paths, XML Web service URLs, commonly used text, or any information that you want to maintain in a central location and be able to change easily.

    Important

    Application settings are stored in the configuration file as plain text. Therefore, you must take appropriate security measures when you use application settings. Do not store sensitive information, such as user names, passwords, or database connection strings in application settings.

  • Simple Mail Transfer Protocol (SMTP) settings.

    If the Web site requires the ability to send e-mail (for example, to send users a password), you must specify the SMTP server that your site uses.

  • Application status.

    You can take your application offline (shut it down) to perform maintenance or to bring a new Microsoft SQL Server Express edition database online.

  • Debugging and tracing.

    Debugging and tracing let you diagnose and fix problems with the Web application, and are primarily intended to be used during development. Enabling debugging causes the pages in the Web site to be compiled with information that the .NET Framework or the Microsoft Visual Studio debugger can use to step through your code. Enabling tracing causes pages to generate information about individual Web requests, the HTTP headers that are sent with the requests, the state of controls on the page, and other details about page processing.

Configuring Application Settings

When you create an application setting, you specify a name and value for the setting to be created. This lets you access the value of the setting in your application by using the AppSettings property of the ConfigurationSettings class. For example, if you define an application setting named AppName with a value that represents the name of your application, you might use it to set the heading of a page as shown in the following code example.

[Visual Basic]

labelPageHeading.Text = ConfigurationManager.AppSettings("AppName")

[C#]

labelPageHeading.Text = ConfigurationManager.AppSettings["AppName"];

Taking Applications Offline and Online

If you want to do maintenance on the Web site, you can take it offline. This shuts the process down that is running the Web site so that the site no longer serves pages. You can then edit pages or other files without the possibility that a page will be requested while you are in the middle of your edits, potentially resulting in an error. Taking an application offline is also useful, if you are working with SQL Server Standard edition and want to swap or add an .mdf database file to the application. If the application is running, it cannot attach to new .mdf files.

When you have finished editing files or adding or changing .mdf files, you can put the application back online.

Configuring SMTP Settings

Some features of the Web site require that your application be able to send e-mail. To send e-mail, the application must have access to a Simple Mail Transfer Protocol (SMTP) server, which forwards e-mail from your application to the e-mail recipient.

IIS) includes an SMTP virtual server, although it is not installed by default. If you want to be able to send e-mail from your own computer, you can install the SMTP server by using Add or Remove Programs in the Microsoft Windows Control Panel. The SMTP server is available as a Windows Component as part of IIS. After you install the IIS SMTP server, you can configure it using the Internet Information Services Management Console. For detailed information about how to install the IIS SMTP virtual server, see the Knowledge Base (KB) search page.

Note

If you install an SMTP server on the computer, you must take security precautions to make sure that the SMTP server is not vulnerable to being used as a spam server. For more information about how to help secure the IIS SMTP virtual server, go to Microsoft.com and search for SMTP security.

If you do not want to install the IIS SMTP server, or if the application will run on a different computer, contact the network or Web server administrator for information about configuration settings for an SMTP server.

The following table describes the SMTP settings.

Setting

Description

Server Name

The name of your SMTP server. The default is localhost, which means that ASP.NET will use an SMTP server on the local computer. Typically, this is the default SMTP virtual server. Otherwise, the name of an SMTP server that is available on the network.

Server Port

The port on your SMTP server. The default is 25.

From

The e-mail address that will appear in the From: header of e-mail messages sent by the Web site.

Authentication

The type of authentication that your SMTP server uses, if any. If your SMTP server uses Basic authentication, provide the account name and password of a user account that is authorized to forward e-mail messages through the server.

The user name and password for Basic authentication are stored in clear text in the Web.config file.

Configuring Debugging and Tracing

You must have Administrative credentials on the computer where the Web application runs to change its debugging and tracing settings.

To manage the debugging and tracing features, clickConfigure debugging and tracing, and then set the following options:

  • Enable Debugging

    Select this option to enable debugging for all pages in the Web site.

  • Capture tracing information

    Select this option to enable tracing for all pages in the Web site. If this check box is selected, the remaining options on the page are enabled.

If you have set the option to capture tracing information, you can make the following choices:

  • Display tracing information on individual pages

    Select this option to append tracing information to the bottom of Web pages on your site. If you do not display tracing information about individual pages, the information is still captured. To view trace information, you can request the Trace.axd page for the Web site, which acts as a tracing information viewer.

  • Local requests only

    Select this option to view trace information only for request from the host Web server (localhost).

  • All requests

    Select this option to view trace information from any computer.

Under Select the sort order for trace results, specify how you want to display trace information, as follows:

  • By time

    Select this option to display trace information in the order that it is captured.

  • By category

    Select this option to display trace information alphabetically within user-defined categories.

  • Number of trace requests to cache

    Enter the number of trace requests to store on the server. You can view cached information by using the trace viewer (https://server/application/trace.axd). The default is 10. If you do not select the Most recent trace results option, and the limit is reached, trace is automatically disabled.

Under Select which trace results to cache, specify how you want to display trace output, as follows:

  • Most recent trace results

    Select this option to display the most recent trace output and to discard older trace data beyond the limits that are indicated by Number of trace requests to cache.

  • Oldest trace results

    Select this option to display trace data for requests until Number of trace requests to cache is reached.

Note

When you are finished troubleshooting the Web site, disable debugging and tracing to get maximum performance from your Web application.

Security noteSecurity Note

When tracing is enabled for a page, trace information might appear on any browser that makes a request for the page from the server. Because tracing displays sensitive information, such as the values of server variables, it can represent a security threat. Make sure that you disable page tracing for the page before publishing the Web application to a production server.

To configure a custom error page for the Web site, clickDefine default error page and then specify the following:

  • Use the default error message

    Select this option to use the default error page.

  • Specify a URL to use as the default error page

    Select this option to use a custom error page, and then choose the page to use.

Behind the Scenes

The Application tab provides a simple Web interface for managing configuration settings that are stored in the Web.config file for your application.

Application Settings

The settings that are managed through the Application Settings feature of the Application tab exist in the <appSettings> section of the Web.config file for the Web application. This is a predefined configuration section provided by the .NET Framework. The highlighted lines in the following code are an example configuration file that is generated after you use the Web Site Administration Tool to create an application setting named ApplicationName.

<configuration>
    <appSettings> 
        <add key="ApplicationName" value="MyApplication" /> 
    </appSettings>
</configuration>

Taking Applications Offline and Online

The offline setting exists within the <httpRuntime> section of the Web.config file for the Web site. The highlighted lines in the following code are generated after you use the Web Site Administration Tool to take an application offline.

<configuration>
    <system.Web>
        <httpRuntime enable="False" />
    </system.Web>
</configuration> 

As long as the httpRuntime setting is disabled, ASP.NET does not create an AppDomain object for your application upon receiving a request. In effect, the Web application cannot be started.

SMTP Settings

The settings that are managed through the SMTP Settings feature of the Application tab exist within the <mailSettings> section of the Web.config file for the Web site, which is a child of the <system.net> element (not of the <system.web> element). The highlighted lines in the following code are generated after you use the Web Site Administration Tool to specify SMTP settings.

<configuration>
    <system.net> 
        <mailSettings> 
            <smtp> 
                <network  
                    host="smtp.myhost.com" /> 
            </smtp> 
        </mailSettings> 
    </system.net>
</configuration>

Debugging and Tracing

The settings managed through the Debugging and Tracing feature of the Application tab exist within the <trace>, <compilation>, and <customErrors> sections of the Web.config file. The following code is an example configuration file that is generated after you use the Web Site Administration Tool to enable both tracing and debugging and to establish a default custom error page.

<configuration>
    <system.Web>
        <customErrors defaultRedirect="~/myErrorPage.aspx" /> 
        <trace enabled="True" pageOutput="True" localOnly="True"  
                traceMode="SortByCategory" 
            requestLimit="10" mostRecent="True" /> 
        <compilation debug="True" />
    </system.Web>
</configuration>

In this example, both debugging and trace are enabled, tracing is displayed on pages that are requested from the Web server only, trace results are sorted by category, and the 10 most recent trace results are cached for display. Additionally, the default error page is myErrorPage.aspx.

More Information

For more information, in the .NET Framework class reference and the ASP.NET Configuration Settings, see the following:

See Also

Concepts

Web Site Administration Tool Overview

Web Site Administration Tool Security Tab

Web Site Administration Tool Provider Tab

Web Site Administration Tool Internals