首页 > 解决方案 > 我收到此错误拒绝访问注册表项“全局”。当我运行 ASP Web 应用程序时

问题描述

我收到此错误拒绝访问注册表项“全局”。当我运行 ASP Web 应用程序时

这是屏幕截图https://prnt.sc/uc4mjm

我还在用户组性能监视器上添加池,这里是 screenshort https://prnt.sc/uc4n8a

我阅读了一些网站帖子并尝试仍然没有解决请帮助我任何人

错误日志

`Server Error in '/' Application.
Access to the registry key 'Global' 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 registry key 'Global' 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 <identity impersonate="true"/>, 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:

The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:

1. Add a "Debug=true" directive at the top of the file that generated the error. Example:

  <%@ Page Language="C#" Debug="true" %>

or:

2) Add the following section to the configuration file of your application:

<configuration>
   <system.web>
       <compilation debug="true"/>
   </system.web>
</configuration>

Note that this second technique will cause all files within a given application to be compiled in debug mode. The first technique will cause only that particular file to be compiled in debug mode.

Important: Running applications in debug mode does incur a memory/performance overhead. You should make sure that an application has debugging disabled before deploying into production scenario.

Stack Trace:


[UnauthorizedAccessException: Access to the registry key 'Global' is denied.]
   Microsoft.Win32.RegistryKey.Win32Error(Int32 errorCode, String str) +5990557
   Microsoft.Win32.RegistryKey.InternalGetValue(String name, Object defaultValue, Boolean doNotExpand, Boolean checkSecurity) +361
   Microsoft.Win32.RegistryKey.GetValue(String name) +62
   System.Diagnostics.PerformanceMonitor.GetData(String item) +148
   System.Diagnostics.PerformanceCounterLib.GetPerformanceData(String item) +255
   System.Diagnostics.PerformanceCounterLib.get_CategoryTable() +172
   System.Diagnostics.PerformanceCounterLib.CounterExists(String category, String counter, Boolean& categoryExists) +35
   System.Diagnostics.PerformanceCounterLib.CounterExists(String machine, String category, String counter) +95
   System.Diagnostics.PerformanceCounter.InitializeImpl() +392
   System.Diagnostics.PerformanceCounter..ctor(String categoryName, String counterName, String instanceName, Boolean readOnly) +373
   System.Diagnostics.PerformanceCounter..ctor(String categoryName, String counterName, String instanceName) +14
   Web_AutoSeeding3.index..ctor() in D:\Project\Web_AutoSeeding3\Web_AutoSeeding3\index.aspx.vb:129
   ASP.index_aspx..ctor() +50
   __ASP.FastObjectFactory_app_web_hbzqzngk.Create_ASP_index_aspx() +72
   System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp) +174
   System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) +42
   System.Web.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +516
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288

`

谢谢朱维尔

标签: asp.net

解决方案


您收到 System.UnauthorizedAccessException 是因为应用程序池无权访问您的网站文件所在的文件夹。

要授予 ASP.NET 对文件的访问权限,

  1. 右键单击文件资源管理器中的文件夹,
  2. 选择Properties并选择Security选项卡。
  3. 点击Edit
  4. 点击Add然后Advanced...
  5. 检查Location字段是否显示正确的系统名称,然后单击Find Now
  6. 选择IIS_IUSERS(检查图像)(如前所述,(通常是 IIS 5 上的 {MACHINE}\ASPNET 或 IIS 6 和 IIS 7 上的网络服务,以及 IIS 7.5 上配置的应用程序池标识),如果应用程序不是模拟的,则使用该标识。如果应用程序通过 模拟,则身份将是匿名用户(通常是 IUSR_MACHINENAME)或经过身份验证的请求用户。)

在此处输入图像描述


推荐阅读