Create Virtual Directory and Set Permissions IIS7 - Cannot read configuration file due to insufficie

Posted by Nick on Stack Overflow See other posts from Stack Overflow or by Nick
Published on 2010-03-19T21:55:52Z Indexed on 2010/03/21 5:11 UTC
Read the original article Hit count: 747

I am trying to create a virtual directory and set it's permissions using IIS7 and C#. Here is a sample of my code:

using (ServerManager serverManager = new ServerManager(webSite))
{
    ConfigurationSection anonymousAuthenticationSection =
      config.GetSection(
          @"system.webServer/security/authentication/anonymousAuthentication",
          webSite);
    anonymousAuthenticationSection["enabled"] = true;

    serverManager.CommitChanges();
    return "true";
}

This throws an exception and the message is:

Cannot read configuration file due to insufficient permissions.

Can someone help?

© Stack Overflow or respective owner

Related posts about iis7

Related posts about configurationsection