Registry key value setting in aspx.page
VB.net code for .aspx page
Dim header As String
Dim footer As String
Dim margin_left As String
Dim margin_top As String
Dim margin_bottom As String
Dim bottom As Double
footer = ""
header = ""
IERegKey = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Internet Explorer\\PageSetup", True)
'footer = IERegKey.GetValue("footer", 0)
'header = IERegKey.GetValue("header", 0)
'margin_top = IERegKey.GetValue("margin_top", 0)
'margin_bottom = IERegKey.GetValue("margin_bottom", 0)
bottom = 0.25
IERegKey.SetValue("footer", "")
'IERegKey.SetValue("header", "")
''IERegKey.SetValue("margin_top", bottom)
'IERegKey.SetValue("margin_bottom", 0)
when project running from working project it will work ok. But when after maki开发者_Python百科ng websetup and try to running page it will show errors as
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 56: 'margin_bottom = IERegKey.GetValue("margin_bottom", 0) Line 57: bottom = 0.25 Line 58: IERegKey.SetValue("footer", "") Line 59: 'IERegKey.SetValue("header", "") Line 60: ''IERegKey.SetValue("margin_top", bottom)
How can i recover the issue please help me
Not sure if I have read your question correct, my understanding is that this project runs for you when you run it in Visual Studio but when you deploy to IIS and try and run your project you get the error message. Is this correct?
I think the problem is due to permissions. When you run it in the Visual Studio's built in web server it's running with your account privileges (I assume you are an admin on your machine) but when hosted in IIS it will run with the permissions assigned to the account which executes the ASP.Net worker process.
I'm not sure what you are trying to achieve but I would not recommend allowing the registry to be modified by the process that runs a web site. Is this configuration that you are looking to store? Could it be placed in a config file or database table?
Alan.
精彩评论