다음을 통해 공유


BindingCollection.RemoveAt(Int32) 메서드

정의

지정된 인덱스에서 바인딩을 제거합니다.

public:
 void RemoveAt(int index);
public void RemoveAt (int index);
override this.RemoveAt : int -> unit
Public Sub RemoveAt (index As Integer)

매개 변수

index
Int32

제거할 바인딩의 인덱스입니다.

예제

다음 예제에서는 "https" 프로토콜을 사용하는 기존 사이트 바인딩에서 유효한 인증서 해시 및 인증서 저장소 이름을 검색합니다. 그런 다음, "*:448:TestingSite"의 바인딩 정보를 지정하여 검색된 인증서 해시 및 인증서 저장소를 사용하여 바인딩 컬렉션에 바인딩을 추가합니다. 마지막으로 ApplicationHost.config 파일을 업데이트하고 새로 정의된 바인딩이 사이트 바인딩 대화 상자에 나타납니다. 바인딩이 이미 있는 경우 바인딩이 삭제되므로 사용자가 바인딩 추가 및 삭제 간에 전환할 수 있습니다. 이 예제는에 대해 제공 된 큰 예제의 일부는 BindingCollection 클래스입니다.

// Adding a duplicate binding throws an error.
if (siteToModify != null)
{
    newbindinginformation = "*:448:TestingSite";
    try
    {
        // Add this binding. It does not already exist. 
        siteToModify.Bindings.Add(newbindinginformation, newcertificateHash, newcertificateStoreName);
    }
    catch
    {
        // Remove this binding. It already exists.
        foreach (Microsoft.Web.Administration.Binding binding in siteToModify.Bindings)
        {
            if (binding.BindingInformation == newbindinginformation)
            {
                bindingIndex = siteToModify.Bindings.IndexOf(binding);
            }
        }
        if (bindingIndex != -1)
        {
            siteToModify.Bindings.RemoveAt(bindingIndex);
        }
    }
    // Update information and save in Administration.config file.
    ManagementUnit.Update();
}

설명

바인딩 요소가 개체에서 BindingCollection 제거되고 메서드로 Update 업데이트되면 ApplicationHost.config 파일에서 삭제됩니다.

바인딩이 삭제되고 ApplicationHost.config 파일이 업데이트되면 삭제된 바인딩이 사이트 바인딩 대화 상자에 더 이상 표시되지 않습니다.

적용 대상