469,602 Members | 1,952 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,602 developers. It's quick & easy.

Change Theme in web.config dynamically in Shared Hosting

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.

Oct 31 '06 #1
0 2023

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

28 posts views Thread by Tony Carnell | last post: by
2 posts views Thread by Joel D Kraft | last post: by
5 posts views Thread by Mart | last post: by
7 posts views Thread by Alan Silver | last post: by
reply views Thread by damiensawyer | last post: by
2 posts views Thread by suresh.csharp | last post: by
2 posts views Thread by Redhairs | last post: by
1 post views Thread by Henry Stock | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.