473,396 Members | 2,036 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,396 software developers and data experts.

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 2197

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

Similar topics

28
by: Tony Carnell | last post by:
Hi all, A couple of days ago I posted a message to this newsgroup relating to the fact that a design I'd worked on for a client wasn't displaying its stylesheet in Mozilla browsers. I was...
2
by: Joel D Kraft | last post by:
I'm using controls in my ASP.NET application from a couple of vendors. Between the vendors and thier versioning, I've set up subfolders under my bin directory: bin bin\Infragistics\v5.2...
5
by: Mart | last post by:
Hi everybody, I plan to have a LOT of SQL string in my app. So I need your advice for this. Is it a good idea to store all my SQL string in the app.config file? For a maintenance point of...
7
by: Alan Silver | last post by:
Hello, I have a web site that uses themes. I would like to have an option on the site owner's administration page where they can set the theme. This page would then write the new value into the...
0
by: damiensawyer | last post by:
Hello all, I'm very new to all of this. I have a theme and a skin (the standard ones). I have a standard master page which is holding a custom ascx which has a treeview in it. Can someone...
2
by: suresh.csharp | last post by:
Hi, I have created two themes in our application. Trying to apply themes on fly to the entire application(all pages..) . 1. In web.config file mentioned <pages theme="theme1" />, It is applying...
2
by: steven | last post by:
hi as many web developers do, i sniff the URL of my app and toggle things like the db connection string, default email recipients, etc dynamically based on what i find (ie. dev.mysite.com,...
2
by: Redhairs | last post by:
The theme item(images,css,skin file) of each theme are under single theme folder of App_Theme. if there are some css or image files which are shared and used by every/some theme, where should I...
1
by: Henry Stock | last post by:
I am having trouble referencing a theme in my ASP.NET project. I was following a model that allowed for multiple themes. So The theme that I have is stored in named "Base" under the App_Theme...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.