对路径 'Global\{xxx}_YYY-YYY:13552' 的访问被拒绝。吊火?

Access to the path 'Global\{xxx}_YYY-YYY:13552' is denied. Hangfire?

正如标题所说,我在我的 MVC 网络应用程序中遇到 "Access to the path" 错误。站点应用程序池是具有身份网络服务的 DefaultAppPool。我已经为网络服务用户设置了完全控制,但没有成功,然后我试图给每个人完全控制,但它仍然不起作用。我是同一文件夹 (C:\Users\YYY\Documents\Visual Studio 2015\Projects) 中的另一个应用程序 运行,它可以正常工作。

失败的文件包含启动Hangfire的方法。会不会跟这个有关系?

我是 运行 Windows 10 Pro 和 IIS 10.0。

public void Start()
{
    lock (_lockObject)
    {
        if (_started) return;
        _started = true;

        HostingEnvironment.RegisterObject(this);

        GlobalConfiguration.Configuration
            .UseSqlServerStorage("connection string");
            // Specify other options here
        _backgroundJobServer = new BackgroundJobServer();
    }
}

http://docs.hangfire.io/en/latest/deployment-to-production/making-aspnet-app-always-running.html

的当前权限

C:\Users\YYY\Documents\Visual Studio 2015\Project

Server Error in '/' Application.

Access to the path 'Global{4deecd4f-19f6-426b-xxxx-xxxxxxxxxxxx}_YYY-YYY:13552' is denied.

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: Access to the path 'Global{4deecd4f-19f6-426b-xxxx-xxxxxxxxxxxx}_YYY-YYY:13552' is denied.

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 , the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

To grant ASP.NET access to a file, right-click the file in File Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.

Source Error:

Line 36: _backgroundJobServer = new BackgroundJobServer();

发现问题,我在同一个应用程序池中有两个使用 Hangfire 运行ning 的网站。当我为每个网站创建一个新的应用程序池时,一切都开始工作了。

当 运行在同一个应用程序池上尝试通过同一个端口进行通信时,Hangfire 的两个实例似乎都是如此,因此第一个启动的应用程序是唯一可以工作的应用程序。他们在同一个应用程序池中开始的原因纯粹是懒惰,我只在本地 IIS 的 Visual Studio 中创建了一个虚拟目录到 运行 项目。