Application.EnabledProtocols 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置为应用程序启用的协议。
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”。TCP“) 接受请求,通过使用包含所需协议的逗号分隔列表设置 EnabledProtocols 属性。
每个站点都可以配置默认协议。 如果未为应用程序显式设置协议, EnabledProtocols 则获取为站点配置的默认协议。 Microsoft.Web.Administration.Site.ApplicationDefaults使用 属性查看站点的默认设置。