首页 文章

当我在iis中托管网站时,给出错误500 ServerManager

提问于
浏览
1
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.Configuration.GetSectionInternal(ConfigurationSection部分)中的Microsoft.Web.Administration.Interop.AppHostWritableAdminManager.GetAdminSection(String bstrSectionName,String bstrSectionPath)\ r \ n ,String sectionPath,String locationPath)\ r \ n在Microsoft.Web.Administration.ServerManager.get_SitesSection()\ r \ n,位于Microsoft.Web.Administration.ServerManager.get_Sites()\ r \ n,位于Krosswall.Setup.Business . SetupBo.Setup(字符串的companyName个)\ r \ n在Krosswall.Setup.Controllers.SetupController.KWSetup(字符串的companyName个)\ r \ n在lambda_method(封闭,对象,对象[])\ r \ n在System.Web.Http .Controllers.ReflectedHttpActionDescriptor.ActionExecutor . <> 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 ---从抛出异常的上一个位置开始的堆栈跟踪结束---在系统中的System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)\ r \ n中的\ r \ n . Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)\ r \ n在System.Web.Http.Controllers.ApiControllerActionInvoker.d__0.MoveNext(个)\ r \ n ---从先前的位置堆栈跟踪,其中引发异常的结束 - - \ r \ n在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)\ r \ n在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)\ r \ n在System.Web.Http.Controllers .ActionFilterResult.d__2.MoveNext()\ r \ n ---堆栈结束从先前的位置追查引发异常--- \ r \ n在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)\ r \ n在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)\ r \ n在System.Web.Http.Controllers.AuthenticationFilterResult.d__0.MoveNext()\ r \ n ---从抛出异常的上一个位置的堆栈跟踪结束--- \ r \ n在System.Runtime.CompilerServices.TaskAwaiter .ThrowForNonSuccess(任务任务)\ r \ n在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)\ r \ n在System.Web.Http.Dispatcher.HttpControllerDispatcher.d__1.MoveNext()“}

wwwroot文件夹权限

https://i.stack.imgur.com/eAQuE.png

Os和IIS描述

https://i.stack.imgur.com/3UUxI.png

1 回答

  • 0

    我不久前遇到过这样的问题 . 您需要确保IIS / IUSRS帐户有权读取/编辑网站所在的文件夹 .

    当您将文件夹从开发位置复制到服务器/计算机上的默认IIS文件夹(wwwRoot)时,通常会发生这种情况,因为权限不是从wwwRoot文件夹继承的 .

    1)找到硬盘上的文件夹(在IIS中指向的文件夹)

    2)右键单击该文件夹,然后单击“属性”

    Folder Properties window
    3)单击“安全”选项卡

    4)单击“编辑”按钮

    5)添加IIS_IUSRS用户(如果它不在列表中),并确保添加正确的权限:read / read execute

    6)确定/保存

    Folder User Permissions window
    注意:您的文件夹位置和名称可能不同 . 它只是您在IIS中指向包含您网站的文件夹 .

    希望有所帮助! :)

相关问题