HttpRedirectSection 클래스
HTTP 리디렉션을 구성합니다.
구문
class HttpRedirectSection : ConfigurationSectionWithCollection
메서드
다음 표에서는 클래스에서 노출하는 메서드를 나열합니다 HttpRedirectSection
.
속성 | 설명 |
---|---|
추가 | ConfigurationSectionWithCollection에서 상속됩니다. |
지우기 | ConfigurationSectionWithCollection 에서 상속됩니다. |
가져오기 | ConfigurationSectionWithCollection 에서 상속됩니다. |
GetAllowDefinition | ( ConfigurationSection에서 상속됩니다.) |
GetAllowLocation | ConfigurationSection 에서 상속됩니다. |
제거 | ConfigurationSectionWithCollection 에서 상속됩니다. |
RevertToParent | ConfigurationSection 에서 상속됩니다. |
SetAllowDefinition | ConfigurationSection 에서 상속됩니다. |
SetAllowLocation | ConfigurationSection 에서 상속됩니다. |
속성
다음 표에서는 클래스에서 노출하는 속성을 나열합니다 HttpRedirectSection
.
속성 | Description |
---|---|
ChildOnly |
읽기/쓰기 boolean 값입니다. true 리디렉션 대상이 원래 URL의 하위 디렉터리에 있으면 이고, 그렇지 않으면 입니다 false . 기본값은 false 입니다. 이 설정은 리디렉션이 한 번만 발생해야 하며 대체 엔진에서 무한 루프를 방지한다는 것을 IIS에 경고합니다. |
Destination |
사용자가 리디렉션되는 파일 이름, 디렉터리 경로 또는 URL을 포함하는 필수 읽기/쓰기 string 값입니다. 문자열에는 원래 URL의 일부를 대상 URL로 전달하는 리디렉션 변수가 포함될 수 있습니다. 문자열에 둘 이상의 변수를 사용할 수 있습니다. |
Enabled |
읽기/쓰기 boolean 값입니다. true HTTP 리디렉션을 사용하도록 설정하면 이고, 그렇지 않으면 입니다 false . 기본값은 false 입니다. |
ExactDestination |
읽기/쓰기 boolean 값입니다. true URL을 절대 위치로 간주해야 하면 이고, 그렇지 않으면 입니다 false . 의 true 설정은 대체 엔진이 원래 요청된 리소스를 리디렉션 URL에 추가하지 못하도록 합니다. |
HttpRedirect |
일치하는 조건을 사용하여 파일 이름, 디렉터리 경로 또는 URL 요청을 지정된 대상으로 리디렉션하는 WildcardRedirectElement 값의 배열입니다. |
HttpResponseStatus |
HTTP 응답 상태 포함하는 읽기/쓰기 sint32 열거형입니다. 가능한 값은 설명 섹션의 뒷부분에 나열됩니다. |
Location |
(에서 ConfigurationSection 상속됨) 키 속성입니다. |
Path |
(에서 ConfigurationSection 상속됨) 키 속성입니다. |
SectionInformation |
ConfigurationSection 에서 상속됩니다. |
를 서브클래싱합니다.
이 클래스에는 하위 클래스가 없습니다.
설명
다음 표에서는 속성에 대해 가능한 값을 나열합니다 HttpResponseStatus
. 기본값은 302(Found
)입니다.
값 | 키워드 | Description |
---|---|---|
301 | Permanent |
IIS는 요청된 리소스의 위치가 영구적으로 변경되었음을 웹 클라이언트에 알릴 수 있습니다. 새 위치는 HTTP 헤더에 Location 지정됩니다. 이 설정을 사용하면 HTTP URL 링크의 레코드를 유지하는 웹 클라이언트가 저장된 URL을 새 위치로 업데이트할 수 있습니다. |
302 | Found |
IIS는 웹 클라이언트에 HTTP 헤더에 지정된 Location 위치에 대한 새 요청을 실행하도록 지시합니다. |
307 | Temporary |
IIS는 원본 데이터를 사용하여 POST 요청을 새 위치로 다시 전송하도록 웹 브라우저에 지시합니다. 일반적으로 웹 브라우저에서 POST 요청을 발급하고 웹 서버에서 302 리디렉션 메시지를 받으면 브라우저는 새 위치에 대한 GET 요청을 발급합니다. 이렇게 하면 원래 POST 요청의 데이터가 손실됩니다. 브라우저에서 307 리디렉션을 수신하는 경우 원래 데이터를 그대로 사용하여 POST를 다시 실행할 수 있습니다. |
예제
첫 번째 예제에서는 포함 SectionInformation
된 HttpRedirect
및 속성을 포함 하 여 클래스의 HttpRedirectSection
모든 속성을 표시 합니다.
두 번째 예제에서는 4개의 와일드카드 리디렉션 요소를 만들고 기본 웹 사이트의 <httpRedirect>
섹션에 추가하려고 시도합니다. 중복 항목이 있는 경우 코드는 이를 보고합니다. 그렇지 않으면 새 항목을 추가합니다. 마지막으로 모든 항목의 새 개수와 각각에 대한 와일드카드 및 대상을 표시합니다.
' 1) First example: Display the httpRedirect properties
' for the default Web site.
' Connect to the WMI WebAdministration namespace.
Set oWebAdmin = _
GetObject("winmgmts:root\WebAdministration")
' Get the httpRedirect section for the default Web site.
Set oSite = oWebAdmin.Get("Site.Name='Default Web Site'")
oSite.GetSection "HttpRedirectSection", oSection
' Display the nonembedded properties.
WScript.Echo "=============================="
WScript.Echo "HttpRedirectSection Properties"
WScript.Echo "=============================="
For Each vProp In oSection.Properties_
If (vProp.Name <> "HttpRedirect") And _
(vProp.Name <> "SectionInformation") Then
WScript.Echo vProp.Name & ": " & vProp.Value
End If
Next
' Display the contents of the SectionInformation property.
WScript.Echo
WScript.Echo "--------------------------------------"
WScript.Echo "HttpRedirectSection.SectionInformation"
WScript.Echo "--------------------------------------"
For Each vProp In oSection.SectionInformation.Properties_
WScript.Echo vProp.Name & ": " & vProp.Value
Next
WScript.Echo
' Display the WildcardRedirectElement instances in the
' HttpRedirect array property.
WScript.Echo "--------------------------------"
WScript.Echo "HttpRedirectSection.HttpRedirect"
WScript.Echo "--------------------------------"
For Each oWildcardRedirectElement In oSection.HttpRedirect
For Each vProp In oWildcardRedirectElement.Properties_
WScript.Echo vProp.Name & ": " & vProp.Value
Next
WScript.Echo
Next
' 2) Second example: Add four WildcardRedirectElement
' instances to the default Web site and display the result.
' Connect to the WMI WebAdministration namespace.
Set oWebAdmin = _
GetObject("winmgmts:root\WebAdministration")
' Get the httpRedirect section for the default Web site.
Set oSite = oWebAdmin.Get("Site.Name='Default Web Site'")
oSite.GetSection "HttpRedirectSection", oSection
' Set up a loop to add four new redirects.
For Counter = 1 To 4
' Create a new instance of WildcardRedirectElement.
' Note that you do not need to use SpawnInstance_.
Set oWildcardRedirect = _
oWebAdmin.Get("WildcardRedirectElement")
' Specify the page to be redirected.
oWildcardRedirect.Wildcard = _
"Adatum.com/Page" & Counter & ".htm"
' Specify the destination for the redirected page.
oWildcardRedirect.Destination = _
"Contoso.com/Page" & Counter & ".htm"
' Prepare to catch duplicate entries.
On Error Resume Next
' Attempt to add the wildcard entry to the collection.
' (You do not need to use Put_ to save the change.)
oSection.Add "HttpRedirect", oWildcardRedirect
' Catch duplicate entries.
If Err.Number = -2147024713 Then
WScript.Echo "Redirect entry for """ & _
oWildcardRedirect.Wildcard & """ already exists."
WScript.Echo
End If
Next
' Update the contents of the oSection variable.
oSection.Refresh_
' Display a header and the new number of entries.
WScript.Echo "--------------------------------"
WScript.Echo "HttpRedirectSection.HttpRedirect"
WScript.Echo "--------------------------------"
WScript.Echo "The number of redirect entries is now " & _
UBound(oSection.HttpRedirect) + 1 & "."
WScript.Echo
' Display the new set of wildcard redirect elements.
For Each oWildcardRedirectElement In oSection.HttpRedirect
WScript.Echo "Wildcard: " & _
oWildcardRedirectElement.Wildcard & vbTab & _
"Destination: " & _
oWildcardRedirectElement.Destination
WScript.Echo
Next
상속 계층 구조
ConfigurationSectionWithCollection
HttpRedirectSection
요구 사항
형식 | Description |
---|---|
클라이언트 | - Windows Vista의 IIS 7.0 - Windows 7의 IIS 7.5 - Windows 8의 IIS 8.0 - WINDOWS 10 IIS 10.0 |
서버 | - Windows Server 2008의 IIS 7.0 - Windows Server 2008 R2의 IIS 7.5 - Windows Server 2012의 IIS 8.0 - Windows Server 2012 R2의 IIS 8.5 - WINDOWS SERVER 2016 IIS 10.0 |
제품 | - IIS 7.0, IIS 7.5, IIS 8.0, IIS 8.5, IIS 10.0 |
MOF 파일 | WebAdministration.mof |
참고 항목
ConfigurationSectionWithCollection 클래스
SectionInformation 클래스
WildcardRedirectElement 클래스