Pet*_*ras 5 asp.net iis binding
这是我的问题的视频摘要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();
}
Run Code Online (Sandbox Code Playgroud)
我得到这个错误:
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.
Run Code Online (Sandbox Code Playgroud)
我已经解决了redirection.config的权限(IUSR和IIS_IUSRS都具有权限)

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

但这仍然行不通。任何建议将不胜感激。
回答
网站不在IIS组下运行。拥有应用程序池的人是用户,这是需要权限的用户。或将该用户放入IIS_IUSRS组。
找出您的应用程序池正在运行的帐户。然后,您需要授予该帐户访问整个%SystemRoot%\System32\inetsrv\config文件夹的权限。仅仅让我访问是不够的%SystemRoot%\System32\inetsrv\config\redirection.config
| 归档时间: |
|
| 查看次数: |
5205 次 |
| 最近记录: |