473,378 Members | 1,138 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Problems accessing registry keys within ASP.NET application

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\InternetExplor er\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
Nov 18 '05 #1
3 1059
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.

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/27cok
"Martin" <ma********@btinternet.com> wrote in message
news:34**************************@posting.google.c om...
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\InternetExplor er\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

Nov 18 '05 #2
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

"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message news:<#M**************@TK2MSFTNGP12.phx.gbl>...
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.

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...

Nov 18 '05 #3
sorry for not being clearer. start here
http://gethelp.devx.com/techtips/nt_.../10min0898.asp
it is a third party component but every bit of it is worth it

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/27cok
"Martin" <ma********@btinternet.com> wrote in message
news:34**************************@posting.google.c om...
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

"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
news:<#M**************@TK2MSFTNGP12.phx.gbl>...
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.

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Arun Bhalla | last post by:
I'm working with VS.NET 2003 and .NET 1.1 (not SP1) on Windows XP SP1. My application is using the Windows Installer Bootstrap. (I may have also installed a module which detects requirements (.NET...
9
by: Swami | last post by:
I was wondering how I can programmatically find out the path of an installed program. I have an application that needs access to a config file that resides in the folder of another application. ...
4
by: Sean Connery | last post by:
I have a Microsoft UI Process Application Block that is controlling child forms in an MDI parent container. The views node in the app.config file has been set to stayOpen=false. Because there...
10
by: BBFrost | last post by:
We just recently moved one of our major c# apps from VS Net 2002 to VS Net 2003. At first things were looking ok, now problems are starting to appear. So far ... (1) ...
3
by: Martin | last post by:
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...
1
by: Yoshitha | last post by:
Hi I am developing web application through which i've to write and read the values from the registry. When i set impersonate property to "false" it is displaying exception " Requested Registry...
4
by: James | last post by:
I have a VB windows forms application that accesses a Microsoft Access database that has been secured using user-level security. The application is being deployed using No-Touch deployment. The...
1
by: James | last post by:
I have a VB windows forms application that accesses a Microsoft Access database that has been secured using user-level security. The application is being deployed using No-Touch deployment. The...
29
by: DFS | last post by:
From an Access 2003 module: v = Shell("ftp.exe -s:D:\ftpCommands.txt") Contents of D:\ftpCommands.txt ---------------------------------- open ftp.destination.com user password send sourceFile...
0
by: tmsprowl | last post by:
Greetings! I was wondering if someone could help me with a problem I'm having. My department is just one of many within my organization. My organization has control over the network domain,...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.