V
vikramp
Hi,
I am storing theme in web.config using <pages theme="mytheme"/>.
I am then using the following code to read it from my webpage:
Configuration config =
WebConfigurationManager.OpenWebConfiguration("~");
PagesSection section =
(PagesSection)config.GetSection("system.web/pages");
string currenttheme = section.Theme;
and then to change the theme and save it back in web.config, I am using
the following code:
Configuration config =
WebConfigurationManager.OpenWebConfiguration("~");
PagesSection section =
(PagesSection)config.GetSection("system.web/pages");
section.Theme = newtheme;
config.Save();
This works perfectly fine on my machine. But when I upload it on my
website, it throws security exception. I am hosting my site on godaddy
with Shared Hosting.
I then made changes in the code for reading the theme: Instead of
saying:
Configuration config =
WebConfigurationManager.OpenWebConfiguration("~");
PagesSection section =
(PagesSection)config.GetSection("system.web/pages");
I changed it to:
PagesSection section =
(PagesSection)WebConfigurationManager.GetSection("system.web/pages");
This worked. But when it comes to saving theme back to web.config, I
get an error "The configuration is read only".
I guess it is because I am on shared hosting and aspnet or
NetworkService account do not have permission to modify web.config,
Is that the reason? or is it something else? Is there any workaround?
Appreciate your help.
Thanks.
I am storing theme in web.config using <pages theme="mytheme"/>.
I am then using the following code to read it from my webpage:
Configuration config =
WebConfigurationManager.OpenWebConfiguration("~");
PagesSection section =
(PagesSection)config.GetSection("system.web/pages");
string currenttheme = section.Theme;
and then to change the theme and save it back in web.config, I am using
the following code:
Configuration config =
WebConfigurationManager.OpenWebConfiguration("~");
PagesSection section =
(PagesSection)config.GetSection("system.web/pages");
section.Theme = newtheme;
config.Save();
This works perfectly fine on my machine. But when I upload it on my
website, it throws security exception. I am hosting my site on godaddy
with Shared Hosting.
I then made changes in the code for reading the theme: Instead of
saying:
Configuration config =
WebConfigurationManager.OpenWebConfiguration("~");
PagesSection section =
(PagesSection)config.GetSection("system.web/pages");
I changed it to:
PagesSection section =
(PagesSection)WebConfigurationManager.GetSection("system.web/pages");
This worked. But when it comes to saving theme back to web.config, I
get an error "The configuration is read only".
I guess it is because I am on shared hosting and aspnet or
NetworkService account do not have permission to modify web.config,
Is that the reason? or is it something else? Is there any workaround?
Appreciate your help.
Thanks.