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

时间:2014-06-22 14:29:50

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

我收到了这个错误:

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

以及此处http://www.codeproject.com/Questions/348972/Error-Cannot-read-configuration-file-due-to-insuff

建议的web.config错误

enter image description here

但它仍然无效。任何建议都会非常感激。

ANSWER

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

2 个答案:

答案 0 :(得分:3)

确定您的应用程序池正在运行的帐户。然后,您需要授予该帐户访问整个var co = require('co'); var app = require('express')(); co(function*() { server = app.listen(3000); yield new Promise((res, rej) => { server.on('listening', res); server.on('error', rej); }); console.log('Listening on port 3000.'); }).catch(function(err) { console.log(err.stack); }); 文件夹的权限。对我来说,只提供%SystemRoot%\System32\inetsrv\config

的访问权限是不够的

答案 1 :(得分:1)

在我的情况下,“以管理员身份运行”解决了问题

相关问题