gpt4 book ai didi

asp.net - 无法以编程方式将绑定(bind)添加到 IIS - redirection.config 权限(带有视频!)

转载 作者:行者123 更新时间:2023-12-03 17:10:31 26 4
gpt4 key购买 nike

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

我正在尝试使用以下代码以编程方式将绑定(bind)添加到 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

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

enter image description here

但它仍然不起作用。

回答

网站不在 IIS 组下运行。拥有应用程序池的人就是用户,这是需要许可的用户。或者将该用户放在 IIS_IUSRS 组中。

最佳答案

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

关于asp.net - 无法以编程方式将绑定(bind)添加到 IIS - redirection.config 权限(带有视频!),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24352251/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com