Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8022913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:24:25+00:00 2026-06-04T22:24:25+00:00

I’m helping build an ASP.NET C# application with multiple custom configuration files. We store

  • 0

I’m helping build an ASP.NET C# application with multiple custom configuration files. We store these outside the web.config file using <configSections><section /></configSections> elements making sure to set restartOnExternalChanges="false" so file saves don’t restart the application.

To manage these settings we’ve built ASPX pages to read, update and save the various sections and values. For plain text sections this works pretty well. Admins log into the configuration section of the app, make changes, save and they take effect immediately.

But we have one section, in its own external file like all the others, that is also encrypted. Whenever that section is saved, the IIS application restarts loosing the session. That means the logged in admin making the configuration changes, and all end users logged into the user side of the app, have to login again which is frustrating.

Is there any way to avoid IIS application restart when an encrypted configuration section is saved?

Our current encrypted config section handling code looks like this:

public class CredentialsConfig : ConfigurationSection
{
    Configuration Config = null;
    CredentialsConfig Section = null;

    public static CredentialsConfig GetConfig()
    {
        Configuration config = WebConfigurationManager.OpenWebConfiguration("~");
        CredentialsConfig section = config.GetSection("credentials") as CredentialsConfig;

        // Ensure the current file is encrypted
        if (!section.SectionInformation.IsProtected)
        {
            section.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
            section.SectionInformation.ForceSave = true;
            config.Save();
        }

        return section;
    }

    public CredentialsConfig GetConfigForUpdate()
    {
        Config = WebConfigurationManager.OpenWebConfiguration("~");
        Section = Config.GetSection("credentials") as CredentialsConfig;
        return Section;
    }

    public void SaveConfig()
    {
        Section.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
        Section.SectionInformation.ForceSave = true;
        Config.Save(ConfigurationSaveMode.Modified);
        ConfigurationManager.RefreshSection("credentials");
    }

    [ConfigurationProperty("administrator")]
    public AdministratorConfigurationElement Administrator
    {
        get
        {
            return this["administrator"] as AdministratorConfigurationElement;
        }
    }
}

And we’re using it like:

CredentialsConfig credentialsConfig = new CredentialsConfig();
AdministratorConfigurationElement newConfig = credentialsConfig.GetConfigForUpdate().Administrator;
// setting attributes in the section's <administrator /> element
credentialsConfig.SaveConfig();
// frustrating app restart happens
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T22:24:27+00:00Added an answer on June 4, 2026 at 10:24 pm

    No. Modifications to the .config file are one of the automatic triggers that will always restart the application.

    Personally, I’d recommend moving commonly modified items out of .config files and into a database, or the registry, or someplace else where it can be encrypted and protected, and where this isn’t an issue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have thousands of HTML files to process using Groovy/Java and I need to
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.