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

标签 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 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. 

要授予 ASP.NET 访问文件的权限,请在资源管理器中右键单击该文件,选择“属性”,然后选择“安全”选项卡。单击“添加”以添加适当的用户或组。突出显示 ASP.NET 帐户,并选中所需访问权限的复选框。

所以错误看起来非常具有描述性。我打开 regedit 并右键单击 KEY (HKEY_CURRENT_USER\Software\Microsoft) --> 权限 --> 添加用户“NETWORK SERIVCE”并授予完全控制权。

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

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

这也没有用。

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

似乎没有任何效果。

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

谢谢!

最佳答案

如果不知道您的 Web 应用程序试图完成什么,就很难进行故障排除。但是,我假设这是一个基于 Web 的应用程序,这意味着您已经为您的 Web 创建了一个数据库。首先,在您的 Web.config'connectionString' 中,尝试使用您用于登录 SQL Server Management 的用户名和密码。不要使用 Windows 登录。其次,尝试使用 F5 功能键运行您的应用程序。这将启动 Visual Studio 2008 附带的内置服务器。这不需要本地 IIS。

如果仍有问题,请发布或发送您的 Web.config。看看我能不能帮忙。

关于c# - 如何授予我的 ASP.NET MVC 应用程序对注册表项的读取访问权限?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4349474/

相关文章:

c# - asp.net中捕获请求静态文件

c# - 向 htmlAttributes 提供值,其中键是 MVC View 中的 C# 保留关键字名称(例如 css "class")

c# - Azure:如何从服务总线队列中删除 "DeadLettered"消息

c# - P/从 C# : Call functions of returned object 调用

c# - 创建一个要出售的广泛项目

c# - 向实体添加新的构造函数

c# - 新窗体上的 STAThread 错误(SaveFileDialog)

c# - ASP.NET Web API 上 HttpActionContext.RequestContentKeyValueModel 的替代方案

c# - 来自 C# 线程创建/删除的 DllMain 调用似乎不平衡?

c# - 如何在 XAML 中动态访问元素名称?