这是我的问题的视频摘要http://screencast.com/t/v6th4BuRLhV
我正在尝试使用以下代码以编程方式将绑定添加到 IIS:
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都有权限)
![enter image description here](https://i.stack.imgur.com/9GSwK.png)
以及此处建议的 web.config 上的错误http://www.codeproject.com/Questions/348972/Error-Cannot-read-configuration-file-due-to-insuff
![enter image description here](https://i.stack.imgur.com/t9fC1.png)
但还是不行。
ANSWER
网站不在 IIS 组下运行。拥有应用程序池的人就是用户,并且这是需要权限的用户。或者将该用户放入 IIS_IUSRS 组中。
找出您的应用程序池正在运行的帐户。然后您需要授予该帐户对整个%SystemRoot%\System32\inetsrv\config
文件夹。对我来说仅仅授予访问权限还不够%SystemRoot%\System32\inetsrv\config\redirection.config
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)