Site.ApplicationDefaults Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the default values for applications that are configured under the current Web site.
public:
property Microsoft::Web::Administration::ApplicationDefaults ^ ApplicationDefaults { Microsoft::Web::Administration::ApplicationDefaults ^ get(); };
public Microsoft.Web.Administration.ApplicationDefaults ApplicationDefaults { get; }
member this.ApplicationDefaults : Microsoft.Web.Administration.ApplicationDefaults
Public ReadOnly Property ApplicationDefaults As ApplicationDefaults
Property Value
An ApplicationDefaults object that represents the configured default values for applications configured for this site.
Examples
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);
}
}
// 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
An ApplicationDefaults object represents the application's configuration values that will be inferred by IIS if the values are not explicitly set. The values are not represented in the object model until they have been written to the configuration system by using the Microsoft.Web.Administration.ServerManager.CommitChanges method and then read back.