开发者

How can I grant my ASP.NET MVC Application Read Access to a registry key?

I have read other posts about how to accomplish this but to no avail. When I deploy my application to the server (2008) I get the following exception at runtime:

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. 

To grant ASP.NET access to a file, right-click the file in 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.

So the error seems very descriptive. I opened regedit and right clicked on the KEY (HKEY_CURRENT_USER\Software\Microsoft) --> Permissions --> Added user 'NETWORK SERIVCE' and granted FULL Control.

I assumed this was the user that ASP.NET was running over to access the registry.

I then tried to disable 'Include inheritable permissions from this object's parent.

This also did not work.

From within IIS Manager, under my application's authentication settings I set the 'anonymous authentication' user to my own which is in in the Administrator's group.

Nothing seems to work.

How can I resolve this issue? This is an internal tool running on our local network so I am not very concerned with security permissions at this stage. How can I grant the appropriate privileges?

Thanks!


It is hard to troubleshoot without knowing what your web application is trying to accomplish. However, I assume this is a web-base application which means you have created a db for your web. First, In your Web.config'connectionString', try using the username and password you used to login to SQL Server Management. Do not use a windows login. Second, trying running your application using F5 function key. This will start a built-in server that came with Visual Studio 2008. This does not require local IIS.

If still having problem, either post or send me your Web.config. See if I can help.


I had to set the Application Pool Identity to "LocalSystem" for this application. This allowed my application enough privileges to read the registry.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜