title: Giving error 500 ServerManager when i host website in iis
body: <pre><code>ServerManager iisManager = new ServerManager();
  var webSiteList = iisManager.Sites;
  </code></pre>
  
  <p>This code is working in Visual studio, but when I host in local IIS it giving 500 error: </p>
  
  <blockquote>
    <p>Error: {
        "Message": "An error has occurred.",
        "ExceptionMessage": "Filename: redirection.config\r\nError: Cannot read configuration file due to insufficient permissions\r\n\r\n",
        "ExceptionType": "System.UnauthorizedAccessException",
        "StackTrace": "   at Microsoft.Web.Administration.Interop.AppHostWritableAdminManager.GetAdminSection(String
    bstrSectionName, String bstrSectionPath)\r\n   at
    Microsoft.Web.Administration.Configuration.GetSectionInternal(ConfigurationSection
    section, String sectionPath, String locationPath)\r\n   at
    Microsoft.Web.Administration.ServerManager.get_SitesSection()\r\n   at
    Microsoft.Web.Administration.ServerManager.get_Sites()\r\n   at
    Krosswall.Setup.Business.SetupBo.Setup(String companyName)\r\n   at
    Krosswall.Setup.Controllers.SetupController.KWSetup(String
    companyName)\r\n   at lambda_method(Closure , Object , Object[] )\r\n 
    at
    System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.&lt;>c__DisplayClass10.b__9(Object
    instance, Object[] methodParameters)\r\n   at
    System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object
    instance, Object[] arguments)\r\n   at
    System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext
    controllerContext, IDictionary`2 arguments, CancellationToken
    cancellationToken)\r\n--- End of stack trace from previous location
    where exception was thrown ---\r\n   at
    System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
    task)\r\n   at
    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
    task)\r\n   at
    System.Web.Http.Controllers.ApiControllerActionInvoker.d__0.MoveNext()\r\n---
    End of stack trace from previous location where exception was thrown
    ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
    task)\r\n   at
    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
    task)\r\n   at
    System.Web.Http.Controllers.ActionFilterResult.d__2.MoveNext()\r\n---
    End of stack trace from previous location where exception was thrown
    ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
    task)\r\n   at
    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
    task)\r\n   at
    System.Web.Http.Controllers.AuthenticationFilterResult.d__0.MoveNext()\r\n---
    End of stack trace from previous location where exception was thrown
    ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
    task)\r\n   at
    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
    task)\r\n   at
    System.Web.Http.Dispatcher.HttpControllerDispatcher.d__1.MoveNext()"
    }</p>
  </blockquote>
  
  <p>wwwroot folder permission </p>
  
  <p><a href="https://i.stack.imgur.com/eAQuE.png" rel="nofollow noreferrer">https://i.stack.imgur.com/eAQuE.png</a></p>
  
  <p>Os and IIS description </p>
  
  <p><a href="https://i.stack.imgur.com/3UUxI.png" rel="nofollow noreferrer">https://i.stack.imgur.com/3UUxI.png</a></p>