2
我正在使用iis 8.0並試圖從列表中刪除任何允許/限制的IP地址,附上屏幕截圖。我通過以下this link使用了刪除變量。從IP安全刪除IP地址<ipSecurity> IIS8.0
var websiteName = "abc.com";
using (var serverManager = new ServerManager())
{
var config = serverManager.GetApplicationHostConfiguration();
var ipSecuritySection = config.GetSection("system.webServer/security/ipSecurity", websiteName);
var ipSecurityCollection = ipSecuritySection.GetCollection();
var addElement = ipSecurityCollection.CreateElement("remove");
addElement["ipAddress"] = ipAddress;
ipSecurityCollection.Remove(addElement);
serverManager.CommitChanges();
}
指導我我做錯了什麼,如果是?那這是什麼。