Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何授予ASP.NET MVC应用程序对注册表项的读取权限?_C#_.net_Asp.net_Asp.net Mvc_Iis 7 - Fatal编程技术网

C# 如何授予ASP.NET MVC应用程序对注册表项的读取权限?

C# 如何授予ASP.NET MVC应用程序对注册表项的读取权限?,c#,.net,asp.net,asp.net-mvc,iis-7,C#,.net,Asp.net,Asp.net Mvc,Iis 7,我读过其他关于如何做到这一点的帖子,但都没有用。当我将应用程序部署到服务器(2008)时,在运行时会出现以下异常: Access to the registry key 'HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\TeamFoundation\Servers' is denied. Description: An unhandled exception occurred during the execution of the cu

我读过其他关于如何做到这一点的帖子,但都没有用。当我将应用程序部署到服务器(2008)时,在运行时会出现以下异常:

Access to the registry key 'HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\TeamFoundation\Servers' 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 'HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\TeamFoundation\Servers' 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) 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. 
对注册表项“HKEY\U CURRENT\U USER\Software\Microsoft\VisualStudio\9.0\TeamFoundation\Servers”的访问被拒绝。
描述:执行当前web请求期间发生未处理的异常。请查看堆栈跟踪以了解有关错误的更多信息以及错误在代码中的起源。
异常详细信息:System.UnauthorizedAccess异常:对注册表项“HKEY\U CURRENT\U USER\Software\Microsoft\VisualStudio\9.0\TeamFoundation\Servers”的访问被拒绝。
ASP.NET无权访问请求的资源。考虑授予对ASP.NET请求标识的资源访问权限。ASP.NET有一个基本进程标识(通常是IIS 5上的{MACHINE}\ASPNET或IIS 6上的网络服务),在应用程序未模拟时使用。如果应用程序是通过模拟的,则标识将是匿名用户(通常是IUSR_MACHINENAME)或经过身份验证的请求用户。
要授予ASP.NET对文件的访问权限,请在资源管理器中右键单击该文件,选择“属性”,然后选择“安全”选项卡。单击“添加”添加相应的用户或组。突出显示ASP.NET帐户,并选中所需访问权限的复选框

因此,这个错误似乎非常具有描述性。我打开regedit并右键单击该键(HKEY_CURRENT_USER\Software\Microsoft)-->权限-->添加了用户“网络服务”并授予完全控制权

我假设这就是ASP.NET正在运行以访问注册表的用户

然后我尝试禁用“包含此对象父对象的可继承权限”

这也不起作用

在IIS管理器中,在我的应用程序的身份验证设置下,我将“匿名身份验证”用户设置为我自己的用户,该用户位于管理员组中

似乎什么都不管用

我如何解决这个问题?这是一个在本地网络上运行的内部工具,所以我不太关心这个阶段的安全权限。我如何授予适当的特权


谢谢

如果不知道您的web应用程序要实现什么目标,就很难进行故障排除。但是,我假设这是一个基于web的应用程序,这意味着您已经为web创建了一个db。首先,在Web.config“connectionString”中,尝试使用用于登录SQL Server管理的用户名和密码。不要使用windows登录。第二,尝试使用F5功能键运行应用程序。这将启动VisualStudio2008附带的内置服务器。这不需要本地IIS


如果仍然有问题,请发布或发送您的Web.config给我。看看我是否能提供帮助。

我必须为此应用程序将应用程序池标识设置为“LocalSystem”。这使我的应用程序有足够的权限读取注册表。

如果将匿名用户设置为网络服务以外的用户,则应授予该用户访问注册表的权限。在尝试执行需要完全信任的此类操作时,我会小心。它可能会回来缠着你。