HostingEnvironmentSection 클래스
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
애플리케이션 호스팅 환경의 동작을 제어하는 구성 설정을 정의합니다. 이 클래스는 상속할 수 없습니다.
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
- 상속
예제
이 예제에서는 클래스의 멤버로 액세스할 수 있는 hostingEnvironment 요소(ASP.NET 설정 스키마) 섹션의 여러 특성에 대해 선언적으로 값을 지정하는 방법을 보여 줍니다.
다음 구성 파일 예제에서는 hostingEnvironment 요소(ASP.NET 설정 스키마) 섹션에 대해 선언적으로 값을 지정하는 방법을 보여 줍니다.
<system.web>
<hostingEnvironment
idleTimeout="20"
shutdownTimeout="30"
/>
</system.web>
다음 코드 예제에서는 클래스를 사용 하는 방법을 보여 줍니다 HostingEnvironmentSection .
#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
설명
HostingEnvironmentSection 클래스는 구성 파일에서 HostingEnvironmentSection 섹션의 값을 프로그래밍 방식으로 액세스하고 수정하는 방법을 제공합니다. ASP.NET 애플리케이션을 지정된 시간 동안 사용하지 않는 경우 IdleTimeout 및 ShutdownTimeout 속성에 따라 메모리에서 언로드할 수 있습니다.
생성자
| Name | Description |
|---|---|
| HostingEnvironmentSection() |
기본 설정을 사용하여 클래스의 새 인스턴스를 HostingEnvironmentSection 초기화합니다. |
속성
| Name | Description |
|---|---|
| CurrentConfiguration |
현재 Configuration 인스턴스가 속한 구성 계층 구조를 나타내는 최상위 ConfigurationElement 인스턴스에 대한 참조를 가져옵니다. (다음에서 상속됨 ConfigurationElement) |
| ElementInformation |
사용자 지정할 수 없는 정보와 ElementInformation 개체의 기능이 포함된 ConfigurationElement 개체를 가져옵니다. (다음에서 상속됨 ConfigurationElement) |
| ElementProperty |
ConfigurationElementProperty 개체 자체를 나타내는 ConfigurationElement 개체를 가져옵니다. (다음에서 상속됨 ConfigurationElement) |
| EvaluationContext |
ContextInformation 개체에 대한 ConfigurationElement 개체를 가져옵니다. (다음에서 상속됨 ConfigurationElement) |
| HasContext |
CurrentConfiguration 속성이 |
| IdleTimeout |
비활성 애플리케이션을 언로드하기 전의 시간(분)을 가져오거나 설정합니다. |
| Item[ConfigurationProperty] |
이 구성 요소의 속성 또는 특성을 가져오거나 설정합니다. (다음에서 상속됨 ConfigurationElement) |
| Item[String] |
이 구성 요소의 속성, 특성 또는 자식 요소를 가져오거나 설정합니다. (다음에서 상속됨 ConfigurationElement) |
| LockAllAttributesExcept |
잠긴 특성의 컬렉션을 가져옵니다. (다음에서 상속됨 ConfigurationElement) |
| LockAllElementsExcept |
잠긴 요소의 컬렉션을 가져옵니다. (다음에서 상속됨 ConfigurationElement) |
| LockAttributes |
잠긴 특성의 컬렉션을 가져옵니다. (다음에서 상속됨 ConfigurationElement) |
| LockElements |
잠긴 요소의 컬렉션을 가져옵니다. (다음에서 상속됨 ConfigurationElement) |
| LockItem |
요소가 잠겨 있는지 여부를 나타내는 값을 가져오거나 설정합니다. (다음에서 상속됨 ConfigurationElement) |
| Properties |
속성의 컬렉션을 가져옵니다. (다음에서 상속됨 ConfigurationElement) |
| SectionInformation |
개체의 SectionInformation 사용자 지정할 수 없는 정보 및 기능을 포함하는 개체를 ConfigurationSection 가져옵니다. (다음에서 상속됨 ConfigurationSection) |
| ShadowCopyBinAssemblies |
Bin에 있는 애플리케이션의 어셈블리가 애플리케이션의 ASP.NET 임시 파일 디렉터리에 섀도 복사되는지 여부를 나타내는 값을 가져오거나 설정합니다. |
| ShutdownTimeout |
애플리케이션을 정상적으로 종료하는 데 걸리는 시간(초)을 가져오거나 설정합니다. |
| UrlMetadataSlidingExpiration |
ASP.NET URL 메타데이터를 캐시하는 방법을 결정하는 값을 가져오거나 설정합니다. |