开发者

Reading from the Registry in ASP.NET

I have a Library ( DLL ) that has a method with the following:

var masterKey =      
    Registry.
    LocalMachine.
    OpenSubKey("SOFTWARE\\Microsoft\\Dynamics\\5.0\\");

When running this method in an WinForms applicaiton, masterKey is not null and when running this in asp.net masterKey is null!

I've checked the executing user with WindowsIdentity.GetCurrent().Name and the same user is executing both applications. The asp.net application is executed in visual studio ( debug: F5 )开发者_如何学Python and so is the WinForms application.

How come I cannot read the key in asp.net?

Edit

I've set the permissions to none what so ever and this gives me "Access Denied". And when I add the group Users I get null. Which would mean that I can fold up the strucutre and see that it's there, but I cannot access the keys/entried.

I am connected to a Domain, but this shouldn't affect my local instances of IIS, should it?


Try granting to Network Service

http://msdn.microsoft.com/en-us/library/ms998320.aspx

The Network Service account does not have write access to the registry. If your application needs to write to the registry, you must configure the necessary access control lists (ACLs) on the required registry keys.


From this MSDN page (which is talking about encryption, but that's not the point):

By default, the ASP.NET process identity used by the Web application will not have access to the registry. Access will need to be explicitly granted.

This ASP.NET forums post describes how to set permissions (in this case for the Event log):

Right click on the [relevant] key and select ... permissions...

Add the account that asp.net is running in to the list. Select the account and make sure read and write is selected.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜