ServerManager iisManager = new ServerManager();
var webSiteList = iisManager.Sites;
此代码在Visual Studio中工作,但是当我在本地IIS中托管时,它会给出500错误:
错误:{ "消息":"发生了错误。", " ExceptionMessage":"文件名:redirection.config \ r \ n错误:由于权限不足\ r \ n \ r \ n"无法读取配置文件, " ExceptionType":" System.UnauthorizedAccessException", " StackTrace":"在Microsoft.Web.Administration.Interop.AppHostWritableAdminManager.GetAdminSection(String bstrSectionName,String bstrSectionPath)\ r \ n at Microsoft.Web.Administration.Configuration.GetSectionInternal(配置节 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(字符串 companyName)\ r \ n在lambda_method(Closure,Object,Object [])\ r \ n 在 System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor<> c__DisplayClass10.b__9(对象 instance,Object [] methodParameters)\ r \ n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(对象 instance,Object [] arguments)\ r \ n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext,IDictionary`2参数,CancellationToken cancellationToken)\ r \ n ---从前一个位置开始的堆栈跟踪结束 抛出异常的地方--- \ r \ n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务 任务)\ r \ n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务 任务)\ r \ n at System.Web.Http.Controllers.ApiControllerActionInvoker.d__0.MoveNext(个)\ r \ n --- 从抛出异常的先前位置开始的堆栈跟踪结束 --- \ r \ n在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务 任务)\ r \ n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务 任务)\ r \ n at System.Web.Http.Controllers.ActionFilterResult.d__2.MoveNext(个)\ r \ n --- 从抛出异常的先前位置开始的堆栈跟踪结束 --- \ r \ n在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务 任务)\ r \ n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务 任务)\ r \ n at System.Web.Http.Controllers.AuthenticationFilterResult.d__0.MoveNext(个)\ r \ n --- 从抛出异常的先前位置开始的堆栈跟踪结束 --- \ r \ n在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务 任务)\ r \ n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务 任务)\ r \ n at System.Web.Http.Dispatcher.HttpControllerDispatcher.d__1.MoveNext()" }
wwwroot文件夹权限
https://i.stack.imgur.com/eAQuE.png
Os和IIS描述
答案 0 :(得分:0)