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

标签 c# visual-studio hangfire

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

失败的文件包含启动 Hangfire 的方法。这可能与它有关吗?

我正在运行带有 IIS 10.0 的 Windows 10 专业版。

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

Security settings

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。当我为每个网站创建一个新的应用程序池时,一切都开始工作了。

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

enter image description here

关于c# - 对路径 'Global\{xxx}_YYY-YYY:13552' 的访问被拒绝。吊火?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33495518/

相关文章:

visual-studio - 每次刷新 mvc web 应用程序时停止 Visual Studio 打开布局页面

c# - BeginExecuteReader、EndExecuteReader 和多个结果

c# - .NET 框架升级指南

c - 对 NaN 值进行签名检查

hangfire - 运行hangfire单线程 "mode"

c#-4.0 - 针对特定异常的 Hangfire 自动重试

c# - 有没有办法让 Newtonsoft.Create 在界面上调用您的自定义创建方法?

c# 初学者对类问题感到沮丧

C# 控制台应用程序值始终为 0

c# - 与 C# 相比,F# 的性能如何?