Microsoft.web.administration 네임 스페이스를 사용하여 IIS7에서 핸들러 매핑을 어떻게 조작합니까?
문제
핸들러 맵핑을 사용하여 Microsoft.Web.Administration
네임 스페이스, 제거하는 방법이 있습니까? <remove name="handler name">
현장 수준에서.
예를 들어, 글로벌 핸들러 매핑 구성의 모든 핸들러 매핑을 상속하는 사이트가 있습니다. ~ 안에 applicationHost.config
그만큼 <location>
태그는 처음에 다음과 같습니다.
<location path="60030 - testsite-60030.com">
<system.webServer>
<security>
<authentication>
<anonymousAuthentication userName="" />
</authentication>
</security>
</system.webServer>
</location>
핸들러를 제거하려면 코드를 사용합니다.
string siteName = "60030 - testsite-60030.com";
string handlerToRemove = "ASPClassic";
using(ServerManager sm = new ServerManager())
{
Configuration siteConfig =
serverManager.GetApplicationHostConfiguration();
ConfigurationSection handlersSection =
siteConfig.GetSection("system.webServer/handlers", siteName);
ConfigurationElementCollection handlersCollection =
handlersSection.GetCollection();
ConfigurationElement handlerElement = handlersCollection
.Where(h => h["name"].Equals(handlerMapping.Name)).Single();
handlersCollection.Remove(handlerElement);
}
이로 인해 사이트가 발생합니다 <location>
태그 모양 :
<location path="60030 - testsite-60030.com">
<system.webServer>
<security>
<authentication>
<anonymousAuthentication userName="" />
</authentication>
</security>
<handlers>
<remove name="ASPClassic" />
</handlers>
</system.webServer>
</location>
여태까지는 그런대로 잘됐다. 그러나 내가 다시 설명한다면 ASPClassic
핸들러는 다음과 같습니다.
<location path="60030 - testsite-60030.com">
<system.webServer>
<security>
<authentication>
<anonymousAuthentication userName="" />
</authentication>
</security>
<handlers>
<remove name="ASPClassic" />
<add name="ASPClassic" path="*.asp" verb="GET,HEAD,POST" modules="IsapiModule" scriptProcessor="%windir%\system32\inetsrv\asp.dll" resourceType="File" />
</handlers>
</system.webServer>
</location>
이로 인해 각 웹 사이트에 대해 시간이 지남에 따라 많은 CRUFT가 발생하여 처리기가 제거 된 다음 프로그래밍 방식으로 다시 추가되었습니다. 그냥 제거하는 방법이 있습니까? <remove name="ASPClassic" />
Microsoft.web.administration 네임 스페이스 코드 사용?
해결책
IIS 제품 팀과 이것을 논의했으며 이것은 구성 시스템의 버그 인 것으로 보입니다. 더 흥미로운 점은 IIS 7.5를 사용하여 Win7 에서이 코드를 시도 할 때 핸들러를 프로그래밍 방식으로 다시 구매할 수 없다는 것입니다. 그렇게하려고 시도하면 COM 예외가 나타납니다.
"오류 : 'aspclassic'으로 설정된 고유 키 속성 '이름'을 사용하여 'Add'의 중복 수집 항목을 추가 할 수 없습니다."
사용자가 위치에 대한 핸들러를 "제거"한 후에는이 버그가 고정 될 때까지 MWA API를 통해 다시 구매할 수 없기 때문에 더 문제가됩니다.