IIS7 handlers accessPolicy

Const  JAKARTA_ISAPI As String = "ISAPI-dll"

Using serverManager As New ServerManager()
	Dim config As Configuration = serverManager.GetWebConfiguration(strWebsiteName, strVirtualDirName)

	Dim handlersSection As ConfigurationSection = config.GetSection("system.webServer/handlers")

	Dim handlersCollection As ConfigurationElementCollection = handlersSection.GetCollection()

	Dim addElement As ConfigurationElement = IISConfigurationSettings.FindElement(handlersCollection, "add", "name", JAKARTA_ISAPI)
	If addElement = Nothing Then
		Throw New InvalidOperationException("Element not found!")
	End If

	addElement("requireAccess") = "Execute"

	serverManager.CommitChanges()
End Using



http://www.iis.net/ConfigReference/system.webServer/handlers
http://www.iis.net/ConfigReference/system.webServer/handlers/add

posted @ 2010-11-12 14:24  大力  阅读(818)  评论(0编辑  收藏  举报