首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法以编程方式向IIS添加绑定- redirection.config权限(带有视频!)

无法以编程方式向IIS添加绑定- redirection.config权限(带有视频!)
EN

Stack Overflow用户
提问于 2014-06-22 14:29:50
回答 2查看 11.8K关注 0票数 11

以下是我的问题http://screencast.com/t/v6th4BuRLhV的视频摘要

我试图用以下代码以编程方式向IIS添加绑定:

代码语言:javascript
复制
public void AddBindings(string sitename, string hostname)
{
  ServerManager serverMgr = new ServerManager();

  Site mySite = serverMgr.Sites[sitename];

  mySite.Bindings.Add("*:80:" + hostname, "http");
  mySite.ServerAutoStart = true;

  serverMgr.CommitChanges();
}

我得到了一个错误:

代码语言:javascript
复制
Filename: redirection.config
Error: Cannot read configuration file due to insufficient permissions

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.UnauthorizedAccessException: Filename: redirection.config
Error: Cannot read configuration file due to insufficient permissions


ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6 and IIS 7, and the configured application pool identity on IIS 7.5) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

我已经解决了redirection.config上的权限( IUSR和IIS_IUSRS都有权限)

以及web.config上的错误(如这里所建议的),http://www.codeproject.com/Questions/348972/Error-Cannot-read-configuration-file-due-to-insuff

但还是没用。

答案

网站不会在IIS组下运行。无论谁拥有应用程序池,都是用户,而这是需要许可的用户。或者将该用户放到IIS_IUSRS组中。

EN

回答 2

Stack Overflow用户

发布于 2017-02-10 23:21:29

找出您的应用程序池正在运行的帐户。然后,您需要让该帐户访问整个%SystemRoot%\System32\inetsrv\config文件夹。对我来说,只允许访问%SystemRoot%\System32\inetsrv\config\redirection.config是不够的

票数 8
EN

Stack Overflow用户

发布于 2020-01-16 15:19:18

在我的例子中,“以管理员身份运行”解决了这个问题。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24352251

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档