ASP.Net web app and the registry

R

Ray Greene

Are there restrictions on accessing the registry from a web
application?

The following code works from a Windows app but from my web app it
gives the error "Object reference not set to an instance of an object"
when it tries to open the key.

Dim strKey As String = "Software\Microsoft\Internet
Explorer\PageSetup"
Dim oKey As RegistryKey = Registry.CurrentUser.OpenSubKey(strKey)
Dim s As String = oKey.GetValue("header", "")
oKey.Close()

However this code works from the web app:

Dim strKey As String = "Software\Microsoft\Windows NT\currentVersion"
Dim oKey As RegistryKey = Registry.LocalMachine.OpenSubKey(strKey)
Dim s As String = oKey.GetValue("ProductID", "")
oKey.Close()

Can I give the web app rights to open and modify the key?
 
C

Cor Ligthert [MVP]

Ray,

I am not sure of you ask this.

You never (in a standard way) can come with a webpage at the registry of the
user.

If you not use it as a rich client which limits the users who can use it to
your own scoop.

Cor
 
R

Ray Greene

Ray,

I am not sure of you ask this.

You never (in a standard way) can come with a webpage at the registry of the
user.

If you not use it as a rich client which limits the users who can use it to
your own scoop.

OK, what I was trying to do was set up IE's print settings
programatically before printing. Is there a way to do this from a web
application?
 
A

Andrew Morton

Ray said:
OK, what I was trying to do was set up IE's print settings
programatically before printing. Is there a way to do this from a web
application?

No. There may be some CSS settings that you can use with "@page" in a
"@media print" section. And some browsers might even not ignore them.

Andrew
 
R

Ray Greene

No. There may be some CSS settings that you can use with "@page" in a
"@media print" section. And some browsers might even not ignore them.

Thanks Andrew, that's not what I wanted to hear but life is full of
little disappointments :)

I tried CSS but IE just ignores it..

I found the ScriptX control at http://www.meadroid.com which looks
quite hopeful so I'll give it a try.
 
C

Cor Ligthert [MVP]

Ray,

Searching for a solution for this is almost forever without sense, if you
find it, than it will be closed probably tomorrow because of security
updates.

What you want is a very high not to be allowed on the security list.

It is a kind of hacking.

Cor
 
A

Andrew Morton

Cor said:
Ray,

Searching for a solution for this is almost forever without sense, if
you find it, than it will be closed probably tomorrow because of
security updates.

What you want is a very high not to be allowed on the security list.

It is a kind of hacking.

If the OP is developing for a closed environment (he specified IE, so it
might be for a corporate intranet), would an ActiveX control be a viable
method for changing the printer settings?

Andrew
 
C

Cor Ligthert [MVP]

Andrew,
If the OP is developing for a closed environment (he specified IE, so it
might be for a corporate intranet), would an ActiveX control be a viable
method for changing the printer settings?

That was my first answer to him, however I got from his answers not the idea
that, that was his goal.
OK, what I was trying to do was set up IE's print settings
programatically before printing. Is there a way to do this from a web
application?

Cor
 
R

Ray Greene

Andrew,


That was my first answer to him, however I got from his answers not the idea
that, that was his goal.

Sorry Cor, I should have explained my situation better. It is a
database report for a corporate environment. Users want to print
without changing print settings every time, but the report is in
landscape format. ScriptX does the job quite nicely.

If IE was a bit smarter then something this trivial would be easy to
do :-(
 

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

Top