Problems accessing registry keys within ASP.NET application

M

Martin

Hi

I am attempting to write a small application that will allow users to
manage the AddressBar entries within Internet Explorer. The typed URLs
in the AddressBar can be found at
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\TypedURLs and I
have successfully managed to get this list via a Windows C# .NET app
with the following code :

public Form1()
{
InitializeComponent();
try
{
RegistryKey key = Registry.CurrentUser;
RegistryKey urlKey =
key.OpenSubKey(@"Software\Microsoft\InternetExplorer\TypedURLs");
keyNames = urlKey.GetValueNames();

foreach(string s in keyNames)
{
lbTypedUrls.Items.Add(urlKey.GetValue(s));
}
}
catch(Exception e)
{
MessageBox.Show(this, "Error Occurred : " + e.Message);
}
}

This works fine and my listbox is correctly populated with the
AdressBar URLs.

However, if I try the same technique in a Web App using the following
code :

private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
try
{
RegistryKey key = Registry.CurrentUser;
RegistryKey urlKey =
key.OpenSubKey(@"Software\Microsoft\Internet Explorer\TypedURLs");
keyNames = urlKey.GetValueNames();

foreach(string s in keyNames)
{
lbTypedUrls.Items.Add(urlKey.GetValue(s).ToString());
}
}
catch(Exception exp)
{
Response.Write("An Error Occurred : " + exp.Message);
}
}
}

I am getting an error stating that, "An Error Occurred : Object
reference not set to an instance of an object."
The line : RegistryKey urlKey =
key.OpenSubKey(@"Software\Microsoft\Internet Explorer\TypedURLs"); Is
failing to load the RegistryKey object.

Can anyone see anything obvious that I am missing or have done wrong?
I don't think this is a permissions error. I have Web.config set up to
impersonate a specific username/password that definately has access to
the reg key.

I have read various other threads were people are receiving Permission
errors but I am not even getting that far :)

The app that I am writing will not be 'Served' over the internet but
will be installed as an App to run on a local machine. I just want to
use IE as the User Interface.

Any help would be greatly appreciated.

Many thanks,
Martin
 
A

Alvin Bruney [MVP]

web applications run under the doctrine of least priviledge (i love that
term). What it means is that you normally do not have permissions to access
the registry unless you explicitly turn that settting on. If you believe you
have turned that setting on then you can use the regmon utility to view the
registry key access.
 
M

Martin

Hi Alvin

Thanks for your reply.

I have to admit that I am not familiar with 'Regmon'. I've just done a
search on my machine and nothing was found with this name.

Can you point me more specifically to the tool I should use.

Regards,
Martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top