HostingEnvironmentSection Klasa

Definicja

Definiuje ustawienia konfiguracji kontrolujące zachowanie środowiska hostingu aplikacji. Klasa ta nie może być dziedziczona.

public ref class HostingEnvironmentSection sealed : System::Configuration::ConfigurationSection
public sealed class HostingEnvironmentSection : System.Configuration.ConfigurationSection
type HostingEnvironmentSection = class
    inherit ConfigurationSection
Public NotInheritable Class HostingEnvironmentSection
Inherits ConfigurationSection
Dziedziczenie

Przykłady

W tym przykładzie pokazano, jak deklaratywnie określić wartości dla kilku atrybutów sekcji hostEnvironment Element (ASP.NET Settings Schema), do której można również uzyskać dostęp jako elementy członkowskie HostingEnvironmentSection klasy.

Poniższy przykładowy plik konfiguracji przedstawia sposób deklaratywnego określania wartości dla sekcji hostingEnvironment Element (ASP.NET Settings Schema).

<system.web>  
  <hostingEnvironment  
    idleTimeout="20"  
    shutdownTimeout="30"  
  />  
</system.web>  

W poniższym przykładzie kodu pokazano, jak używać HostingEnvironmentSection klasy .

#region Using directives

using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using System.Web;
using System.Web.Configuration;

#endregion

namespace Samples.Aspnet.SystemWebConfiguration
{
  class UsingHostingEnvironmentSection
  {
    static void Main(string[] args)
    {
      try
      {
        // Set the path of the config file.
        string configPath = "";
 
        // Get the Web application configuration object.
        Configuration config = WebConfigurationManager.OpenWebConfiguration(configPath);

        // Get the section related object.
        HostingEnvironmentSection configSection = 
          (HostingEnvironmentSection)config.GetSection("system.web/hostingEnvironment");

        // Display title and info.
        Console.WriteLine("ASP.NET Configuration Info");
        Console.WriteLine();

        // Display Config details.
        Console.WriteLine("File Path: {0}", config.FilePath);
        Console.WriteLine("Section Path: {0}", configSection.SectionInformation.Name);

        // Display IdleTimout property
        Console.WriteLine("Idle Timeout: {0}", configSection.IdleTimeout);

        // Set IdleTimout property
        configSection.IdleTimeout = TimeSpan.FromMinutes(40);

        // Display ShutdownTimeout property
        Console.WriteLine("Shutdown Timeout: {0}", configSection.ShutdownTimeout);

        // Set ShutdownTimeout property
        configSection.ShutdownTimeout = TimeSpan.FromSeconds(60);

        // Update if not locked.
        if (!configSection.SectionInformation.IsLocked)
        {
          config.Save();
          Console.WriteLine("** Configuration updated.");
        }
        else
        {
          Console.WriteLine("** Could not update, section is locked.");
        }
      }
      catch (Exception e)
        {
          // Unknown error.
          Console.WriteLine(e.ToString());
        }

      // Display and wait
      Console.ReadLine();
    }
  }
}
Imports System.Collections.Generic
Imports System.Text
Imports System.Configuration
Imports System.Web
Imports System.Web.Configuration

Namespace Samples.Aspnet.SystemWebConfiguration
  Class UsingSiteMapSection
    Public Shared Sub Main()
      Try
        ' Set the path of the config file.
        Dim configPath As String = ""

        ' Get the Web application configuration object.
        Dim config As System.Configuration.Configuration = _
         System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(configPath)

        ' Get the section related object.
        Dim configSection As System.Web.Configuration.HostingEnvironmentSection = _
         CType(config.GetSection("system.web/hostingEnvironment"), System.Web.Configuration.HostingEnvironmentSection)

        ' Display title and info.
        Console.WriteLine("ASP.NET Configuration Info")
        Console.WriteLine()

        ' Display Config details.
        Console.WriteLine("File Path: {0}", config.FilePath)
        Console.WriteLine("Section Path: {0}", configSection.SectionInformation.Name)

        ' Display the IdleTimout property
        Console.WriteLine("Idle Timeout: {0}", configSection.IdleTimeout)

        ' Set the IdleTimout property
        configSection.IdleTimeout = TimeSpan.FromMinutes(40)

        ' Display the ShutdownTimeout property
        Console.WriteLine("Shutdown Timeout: {0}", configSection.ShutdownTimeout)

        ' Set the ShutdownTimeout property
        configSection.ShutdownTimeout = TimeSpan.FromSeconds(60)

        ' Update if not locked.
        If Not configSection.SectionInformation.IsLocked Then
          config.Save()
          Console.WriteLine("** Configuration updated.")
        Else
          Console.WriteLine("** Could not update, section is locked.")
        End If

      Catch e As Exception
        ' Unknown error.
        Console.WriteLine(e.ToString())
      End Try

      ' Display and wait
      Console.ReadLine()
    End Sub
  End Class
End Namespace

Uwagi

Klasa HostingEnvironmentSection umożliwia programowy dostęp i modyfikowanie wartości HostingEnvironmentSection sekcji w pliku konfiguracji. Gdy aplikacja ASP.NET jest nieużywane przez określony czas, można ją zwolnić z pamięci na IdleTimeout podstawie właściwości i ShutdownTimeout .

Konstruktory

HostingEnvironmentSection()

Inicjuje HostingEnvironmentSection nowe wystąpienie klasy przy użyciu ustawień domyślnych.

Właściwości

CurrentConfiguration

Pobiera odwołanie do wystąpienia najwyższego poziomu Configuration reprezentującego hierarchię konfiguracji, do którego należy bieżące ConfigurationElement wystąpienie.

(Odziedziczone po ConfigurationElement)
ElementInformation

ElementInformation Pobiera obiekt, który zawiera informacje i funkcje ConfigurationElement obiektu, które nie można dostosowywać.

(Odziedziczone po ConfigurationElement)
ElementProperty

ConfigurationElementProperty Pobiera obiekt reprezentujący ConfigurationElement sam obiekt.

(Odziedziczone po ConfigurationElement)
EvaluationContext

ContextInformation Pobiera obiekt dla ConfigurationElement obiektu.

(Odziedziczone po ConfigurationElement)
HasContext

Pobiera wartość wskazującą CurrentConfiguration , czy właściwość ma wartość null.

(Odziedziczone po ConfigurationElement)
IdleTimeout

Pobiera lub ustawia czas (w minutach) przed zwolnieniem nieaktywnej aplikacji.

Item[ConfigurationProperty]

Pobiera lub ustawia właściwość lub atrybut tego elementu konfiguracji.

(Odziedziczone po ConfigurationElement)
Item[String]

Pobiera lub ustawia właściwość, atrybut lub element podrzędny tego elementu konfiguracji.

(Odziedziczone po ConfigurationElement)
LockAllAttributesExcept

Pobiera kolekcję zablokowanych atrybutów.

(Odziedziczone po ConfigurationElement)
LockAllElementsExcept

Pobiera kolekcję zablokowanych elementów.

(Odziedziczone po ConfigurationElement)
LockAttributes

Pobiera kolekcję zablokowanych atrybutów.

(Odziedziczone po ConfigurationElement)
LockElements

Pobiera kolekcję zablokowanych elementów.

(Odziedziczone po ConfigurationElement)
LockItem

Pobiera lub ustawia wartość wskazującą, czy element jest zablokowany.

(Odziedziczone po ConfigurationElement)
Properties

Pobiera kolekcję właściwości.

(Odziedziczone po ConfigurationElement)
SectionInformation

SectionInformation Pobiera obiekt, który zawiera informacje i funkcje ConfigurationSection obiektu, które nie można dostosowywać.

(Odziedziczone po ConfigurationSection)
ShadowCopyBinAssemblies

Pobiera lub ustawia wartość wskazującą, czy zestawy aplikacji w Pojemniku są kopiowane w tle do katalogu plików tymczasowych aplikacji ASP.NET.

ShutdownTimeout

Pobiera lub ustawia czas w sekundach, aby bezpiecznie zamknąć aplikację.

UrlMetadataSlidingExpiration

Pobiera lub ustawia wartość, która określa, jak ASP.NET buforuje metadane adresu URL.

Metody

DeserializeElement(XmlReader, Boolean)

Odczytuje kod XML z pliku konfiguracji.

(Odziedziczone po ConfigurationElement)
DeserializeSection(XmlReader)

Odczytuje kod XML z pliku konfiguracji.

(Odziedziczone po ConfigurationSection)
Equals(Object)

Porównuje bieżące ConfigurationElement wystąpienie z określonym obiektem.

(Odziedziczone po ConfigurationElement)
GetHashCode()

Pobiera unikatową wartość reprezentującą bieżące ConfigurationElement wystąpienie.

(Odziedziczone po ConfigurationElement)
GetRuntimeObject()

Zwraca obiekt niestandardowy, gdy zostanie zastąpiony w klasie pochodnej.

(Odziedziczone po ConfigurationSection)
GetTransformedAssemblyString(String)

Zwraca przekształconą wersję określonej nazwy zestawu.

(Odziedziczone po ConfigurationElement)
GetTransformedTypeString(String)

Zwraca przekształconą wersję określonej nazwy typu.

(Odziedziczone po ConfigurationElement)
GetType()

Type Pobiera wartość bieżącego wystąpienia.

(Odziedziczone po Object)
Init()

ConfigurationElement Ustawia obiekt na stan początkowy.

(Odziedziczone po ConfigurationElement)
InitializeDefault()

Służy do inicjowania domyślnego zestawu wartości dla ConfigurationElement obiektu.

(Odziedziczone po ConfigurationElement)
IsModified()

Wskazuje, czy ten element konfiguracji został zmodyfikowany od czasu ostatniego zapisania lub załadowania podczas implementacji w klasie pochodnej.

(Odziedziczone po ConfigurationSection)
IsReadOnly()

Pobiera wartość wskazującą, czy ConfigurationElement obiekt jest tylko do odczytu.

(Odziedziczone po ConfigurationElement)
ListErrors(IList)

Dodaje błędy nieprawidłowej właściwości w tym ConfigurationElement obiekcie i we wszystkich podelementach do przekazanej listy.

(Odziedziczone po ConfigurationElement)
MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
OnDeserializeUnrecognizedAttribute(String, String)

Pobiera wartość wskazującą, czy podczas deserializacji napotkano nieznany atrybut.

(Odziedziczone po ConfigurationElement)
OnDeserializeUnrecognizedElement(String, XmlReader)

Pobiera wartość wskazującą, czy podczas deserializacji napotkano nieznany element.

(Odziedziczone po ConfigurationElement)
OnRequiredPropertyNotFound(String)

Zgłasza wyjątek, gdy nie można odnaleźć wymaganej właściwości.

(Odziedziczone po ConfigurationElement)
PostDeserialize()

Wywoływana po deserializacji.

(Odziedziczone po ConfigurationElement)
PreSerialize(XmlWriter)

Wywoływana przed serializacji.

(Odziedziczone po ConfigurationElement)
Reset(ConfigurationElement)

Resetuje stan ConfigurationElement wewnętrzny obiektu, w tym blokady i kolekcje właściwości.

(Odziedziczone po ConfigurationElement)
ResetModified()

Resetuje wartość IsModified() metody w false przypadku implementacji w klasie pochodnej.

(Odziedziczone po ConfigurationSection)
SerializeElement(XmlWriter, Boolean)

Zapisuje zawartość tego elementu konfiguracji do pliku konfiguracji po zaimplementowaniu w klasie pochodnej.

(Odziedziczone po ConfigurationElement)
SerializeSection(ConfigurationElement, String, ConfigurationSaveMode)

Tworzy ciąg XML zawierający nieskonwergentny widok ConfigurationSection obiektu jako pojedynczą sekcję do zapisu w pliku.

(Odziedziczone po ConfigurationSection)
SerializeToXmlElement(XmlWriter, String)

Zapisuje zewnętrzne tagi tego elementu konfiguracji do pliku konfiguracji po zaimplementowaniu w klasie pochodnej.

(Odziedziczone po ConfigurationElement)
SetPropertyValue(ConfigurationProperty, Object, Boolean)

Ustawia właściwość na określoną wartość.

(Odziedziczone po ConfigurationElement)
SetReadOnly()

IsReadOnly() Ustawia właściwość dla ConfigurationElement obiektu i wszystkich podelementów.

(Odziedziczone po ConfigurationElement)
ShouldSerializeElementInTargetVersion(ConfigurationElement, String, FrameworkName)

Wskazuje, czy określony element powinien być serializowany, gdy hierarchia obiektów konfiguracji jest serializowana dla określonej wersji docelowej .NET Framework.

(Odziedziczone po ConfigurationSection)
ShouldSerializePropertyInTargetVersion(ConfigurationProperty, String, FrameworkName, ConfigurationElement)

Wskazuje, czy określona właściwość powinna być serializowana, gdy hierarchia obiektów konfiguracji jest serializowana dla określonej wersji docelowej .NET Framework.

(Odziedziczone po ConfigurationSection)
ShouldSerializeSectionInTargetVersion(FrameworkName)

Wskazuje, czy bieżące ConfigurationSection wystąpienie powinno być serializowane, gdy hierarchia obiektów konfiguracji jest serializowana dla określonej wersji docelowej .NET Framework.

(Odziedziczone po ConfigurationSection)
ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)
Unmerge(ConfigurationElement, ConfigurationElement, ConfigurationSaveMode)

Modyfikuje obiekt w ConfigurationElement celu usunięcia wszystkich wartości, które nie powinny być zapisywane.

(Odziedziczone po ConfigurationElement)

Dotyczy

Zobacz też