无法以编程方式向IIS添加绑定-redirection.config权限(带有视频!) [英] Cant add bindings to IIS programmatically - redirection.config permissions (with a video!)

查看:200
本文介绍了无法以编程方式向IIS添加绑定-redirection.config权限(带有视频!)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Here is a video summary of my problem http://screencast.com/t/v6th4BuRLhV

我正在尝试使用以下代码以编程方式将绑定添加到IIS:

I am trying to add bindings programmatically to IIS with this code:

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();
}

我收到此错误:

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都具有权限)

I have addressed the permissions on redirection.config (both IUSR and IIS_IUSRS have permissions)

以及此处建议的web.config错误 http://www.codeproject.com/Questions/348972/Error-Cannot-read-configuration-file-due-to-insuff

As well as the errors on web.config as suggested here http://www.codeproject.com/Questions/348972/Error-Cannot-read-configuration-file-due-to-insuff

但是它仍然不起作用.

答案

网站不在IIS组下运行.拥有应用程序池的人是用户,这是需要权限的用户.或将该用户放入IIS_IUSRS组.

Websites don't run under the IIS group. Whoever owns the app pool is the user and this is the user that needs permission. Or put that user in the IIS_IUSRS group.

推荐答案

找出您的应用程序池以哪个帐户运行.然后,您需要授予该帐户访问整个%SystemRoot%\System32\inetsrv\config文件夹的权限.仅授予%SystemRoot%\System32\inetsrv\config\redirection.config

Figure out what account your application pool is running as. Then you need to give that account access to the entire %SystemRoot%\System32\inetsrv\config folder. It wasn't enough for me to give access to just %SystemRoot%\System32\inetsrv\config\redirection.config

这篇关于无法以编程方式向IIS添加绑定-redirection.config权限(带有视频!)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆