我正在尝试使用 c# 在站点上打开匿名身份验证
这段代码抛出了写在底部的异常我到处搜索我找不到答案如何解决它:
using (ServerManager serverManager = new ServerManager())
{
Configuration configapp = serverManager.GetApplicationHostConfiguration();
ConfigurationSection anonymousAuthenticationSection = configapp.GetSection("system.webServer/security/authentication/anonymousAuthentication", Site1);
anonymousAuthenticationSection["enabled"] = false;
serverManager.CommitChanges();
}
例外:
System.IO.FileNotFoundException: Filename: \\?\C:\Windows\system32\inetsrv\config\applicationHost.config
Error: Unrecognized configuration path 'MACHINE/WEBROOT/APPHOST/Site1'
at Microsoft.Web.Administration.Interop.AppHostWritableAdminManager.GetAdminSection(String bstrSectionName, String bstrSectionPath)
at Microsoft.Web.Administration.Configuration.GetSectionInternal(ConfigurationSection section, String sectionPath, String locationPath)
at Microsoft.Web.Administration.Configuration.GetSection(String sectionPath, String locationPath)
at FlowSuiteWebConfigurator.label.button1_Click(Object sender, EventArgs e) in C:\Users\Administrator\documents\visual studio 2010\Projects\Projectname\Projectname\Form1.cs:line 264
有人可以指导我如何解决这个问题吗?