ApplicationDefaults.EnabledProtocols Property

Definition

Gets or sets the protocols that are enabled by default for all applications under the current Web site.

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

Property Value

A comma-delimited list of the protocols that are enabled for all applications under the current site by default. The default is "http".

Examples

The following example displays the default application values for each site.

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

namespace AdministrationSnippets
{
    public class AdministrationApplicationDefaults
    {
// Displays the default application values for all configured sites.
public void GetApplicationDefaults()
{
    ServerManager manager = new ServerManager();
    foreach (Site s in manager.Sites)
    {
        ApplicationDefaults d = s.ApplicationDefaults;
        Console.WriteLine("Site: {0}", s.Name);
        Console.WriteLine("  |--Default Application Pool:  {0}", 
            d.ApplicationPoolName);
        Console.WriteLine("  +--Default Protocols Enabled: {0}\r\n", 
            d.EnabledProtocols);
    }

}
    }
}

The following example sets the default values for applications created under the default Web site, creates a new application, and then verifies that the application properties are set to the default values.

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

namespace AdministrationSnippets
{
    public class AdministrationApplicationDefaults
    {
// Sets the default values for applications configured under the 
// default Web site.
public void SetApplicationDefaults()
{
    ServerManager manager = new ServerManager();
    Site defaultSite = manager.Sites["Default Web Site"];
    ApplicationDefaults defaultVals = defaultSite.ApplicationDefaults;

    // Set the application defaults.
    defaultVals.ApplicationPoolName = "CommunitySites";
    defaultVals.EnabledProtocols = "http";
    
    // Create a new application.
    defaultSite.Applications.Add(
        "/discussion", @"C:\inetpub\wwwroot\forums");
    manager.CommitChanges();

    // Read the application's values.
    Application discussion = defaultSite.Applications["/discussion"];
    Console.WriteLine("Site: {0}", defaultSite.Name);
    Console.WriteLine("  |--Default Application Pool:  {0}", 
        discussion.ApplicationPoolName);
    Console.WriteLine("  +--Default Protocols Enabled: {0}\r\n", 
        discussion.EnabledProtocols);
}
    }
}

Remarks

This property specifies the default protocols that requests can use to access an application. The default value is "http", which enables both the HTTP and HTTPS protocols. A value of "https" also enables both HTTP and HTTPS.

If the protocols are not explicitly set for an application, Microsoft.Web.Administration.Application.EnabledProtocols returns the value configured by this property.

Applies to

See also