语言

Application.EnabledProtocols 属性

定义

获取或设置为应用程序启用的协议。

public:
 property System::String ^ EnabledProtocols { System::String ^ get(); void set(System::String ^ value); };
public string EnabledProtocols { get; set; }
member this.EnabledProtocols : string with get, set
Public Property EnabledProtocols As String

属性值

为应用程序启用的协议的逗号分隔列表。 默认值为“http”。

示例

以下示例读取现有站点的配置。 该代码显示从 EnabledProtocols 默认网站下配置的应用程序的属性返回的值。

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Web.Administration;
using Microsoft.Web.Management;

namespace AdministrationSnippets
{
    public class AdministrationApplicationEnabledProtocols
    {
// Writes out the applications and the protocols enabled for 
// each application under the default Web site.
public void GetEnabledProtocols()
{
    ServerManager manager = new ServerManager();
    Site defaultSite = manager.Sites["Default Web Site"];

    foreach (Application app in defaultSite.Applications)
    {
        Console.WriteLine(
            "{0} has enabled the following protocols: '{1}'", 
            app.Path, app.EnabledProtocols);
    }
}
    }
}

注解

此属性指定请求可用于访问应用程序的协议。 默认值为“http”,它同时启用 HTTP 和 HTTPS 协议。 “https”的值还启用 HTTP 和 HTTPS。 如果在属性中 EnabledProtocols 未指定“http”和“https”,则为应用程序禁用 HTTP 和 HTTPS。 如果只想接受 HTTPS 请求,请为站点配置安全套接字层 (SSL) 功能。

如果站点需要其他协议(如“NET”。若要接受请求,请使用逗号分隔的列表来设置 EnabledProtocols 属性,其中包括所需的协议。

每个站点都可以配置默认协议。 如果未为应用程序显式设置协议, EnabledProtocols 则获取为站点配置的默认协议。 使用属性 Microsoft.Web.Administration.Site.ApplicationDefaults 查看网站的默认设置。

适用于