我想创建一个虚拟目录并使用IIS7和C#设置它的权限。这里是我的代码示例:创建虚拟目录并设置权限IIS7 - 由于权限不足,无法读取配置文件
using (ServerManager serverManager = new ServerManager(webSite))
{
ConfigurationSection anonymousAuthenticationSection =
config.GetSection(
@"system.webServer/security/authentication/anonymousAuthentication",
webSite);
anonymousAuthenticationSection["enabled"] = true;
serverManager.CommitChanges();
return "true";
}
这会抛出一个异常消息是:
Cannot read configuration file due to insufficient permissions.
有人能帮忙吗?
编辑
与管理权限运行给了我一个新的错误:“启用读取配置文件”谁能告诉我这配置应该读,我怎么能访问它?
你在使用Window Vista吗?很可能你必须从控制面板禁用UAC。 – wonde 2010-03-20 04:11:21
Server 2008 64。 – Nick 2010-03-22 22:36:07