【发布时间】:2011-12-22 04:40:06
【问题描述】:
我需要在我的 IIS Web 服务应用程序中设置特定 asp.net 文件的身份验证模型。主题“如何以编程方式在 .NET Web 服务上的 IIS 中设置集成 Windows 身份验证?”基本上做我想要的,但对于整个网站。我需要拥有除一项网络服务匿名访问之外的所有服务,但需要使用“Windows 身份验证”
像这样:
应用此代码时,我无法弄清楚如何指定某个文件:
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();
【问题讨论】: