我有一个Web服务项目需要设置为在安装后使用集成Windows身份验证。通常,我会安装Web服务,然后手动转到IIS并确保选中“集成Windows身份验证”框。必须有一种方法可以通过代码执行此操作。我已经查看了使用Installer类。看起来这是我可以使用的东西,但我还没有在IIS中以编程方式设置属性。
答案 0 :(得分:2)
String applicationPath = String.Format("{0}/{1}", _server.Sites["Default Web Site"].Name, "AppName");
Configuration config = _server.GetApplicationHostConfiguration();
ConfigurationSection anonymousAuthenticationSection = config.GetSection("system.webServer/security/authentication/anonymousAuthentication", applicationPath);
anonymousAuthenticationSection["enabled"] = false;
ConfigurationSection windowsAuthenticationSection = config.GetSection("system.webServer/security/authentication/windowsAuthentication", applicationPath);
windowsAuthenticationSection["enabled"] = true;
_server.CommitChanges();
答案 1 :(得分:0)
看看WebDeploy。这项技术由MS设计,用于部署Web应用程序。 ; - )