473,573 Members | 2,768 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Change Theme in web.config dynamically in Shared Hosting


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 =
WebConfiguratio nManager.OpenWe bConfiguration( "~");
PagesSection section =
(PagesSection)c onfig.GetSectio n("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 =
WebConfiguratio nManager.OpenWe bConfiguration( "~");
PagesSection section =
(PagesSection)c onfig.GetSectio n("system.web/pages");
section.Theme = newtheme;

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

Configuration config =
WebConfiguratio nManager.OpenWe bConfiguration( "~");
PagesSection section =
(PagesSection)c onfig.GetSectio n("system.web/pages");

I changed it to:
PagesSection section =
(PagesSection)W ebConfiguration Manager.GetSect ion("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.


Oct 31 '06 #1
0 2214

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

Similar topics

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 advised by a couple of other newsgroup members far more knowledgeable that I on this subject that I should contact the Web host and ask them to alter the...
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 bin\RadControls\v5.3 Under 2.0b2, I had the following setup in my web.config: <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
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 vue it would be easy to access and change any SQL squery without having to open/edit any forms.
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 web.config file. I can't seem to work out how to do this. I guess I need to use the AppSettingsSection class, but I'm not sure. I can't find any...
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 please point me in the right direction to bind a theme to the treeview? The 'theme' tag is on the <%@ page %> directive... however neither my master...
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 for the entire site. 2. In each Page, PreInit event menthod if I mention Page.Theme = Profile.MyTheme; It is applying the theme to which ever...
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, qa.mysite.com, mysite.com). this way, i don't have to worry about updating my web.config file everytime i want to deploy my app from DEV to QA to...
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 put them ?
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 folder that is stored at the root of my project folder. It is really the one I want to use for all pages, so I thought I would reference it in the...
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.