Change Theme in web.config dynamically in Shared Hosting

Discussion in 'ASP .Net' started by vikramp, Oct 31, 2006.

  1. vikramp

    vikramp Guest

    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.
    vikramp, Oct 31, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sam-I-Am
    Replies:
    3
    Views:
    7,394
    Steven Cheng[MSFT]
    Jul 21, 2004
  2. Sachin
    Replies:
    3
    Views:
    847
    Alan Silver
    Mar 1, 2006
  3. Andrew Jocelyn

    Theme not set in web.config PagesSection

    Andrew Jocelyn, Mar 5, 2009, in forum: ASP .Net
    Replies:
    7
    Views:
    1,968
    Allen Chen [MSFT]
    Mar 13, 2009
  4. Jazza
    Replies:
    3
    Views:
    288
    Dominick Baier
    Jun 13, 2007
  5. teo1991
    Replies:
    0
    Views:
    515
    teo1991
    Apr 2, 2009
Loading...

Share This Page