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 5976655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:15:34+00:00 2026-05-22T21:15:34+00:00

Here is my c# code : System.Configuration.Configuration config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(~/Web.config); ConfigurationSection section = config.GetSection(appSettings);

  • 0

Here is my c# code :

System.Configuration.Configuration config =
    System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~/Web.config");

ConfigurationSection section = config.GetSection("appSettings");
section.SectionInformation.ProtectSection("RsaProtectedConfigurationProvider");
section.SectionInformation.ForceSave = true;        
config.Save(ConfigurationSaveMode.Modified);
string sectionXml = section.SectionInformation.GetRawXml();

I need to encrypt web.config programatically, but it gives me error:

A configuration file cannot be created for the requested Configuration object.

  • 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-05-22T21:15:35+00:00Added an answer on May 22, 2026 at 9:15 pm

    The error is on the ~/web.config, the OpenWebConfiguration needs the full application path, not the name of the web.config as appears on web.

    Try this (tested and working for the opening):

    OpenWebConfiguration(HttpContext.Current.Request.ApplicationPath);
    

    or (base on msdn sample code)

    OpenWebConfiguration(/web.config);
    

    or even call it with null, as MSDN notes.

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

Sidebar

Related Questions

Using the obsolete System.Web.Mail sending email works fine, here's the code snippet: Public Shared
This is regarding a web.config file Here's the ConfigSection <configSections> <sectionGroup name=HttpExceptionHandler> <section name=errorLog
here is a code : using System; using Nemerle.Collections; using Nemerle.Text; //using Nemerle.Utility; using
So here is the simple code: [System.ComponentModel.DefaultValue(true)] public bool AnyValue { get; set; }
Here is my code : public static void main(String[] args) { // System.setProperty( //
I am having some trouble opening a custom config section in my web.config file.
I have code that relies heavily on email notification. In my web.config I am
My config file is located here: ~/Admin/Web.config I tried opening it via the below
I am having issues accessing my ConnectionString in the web config. Here is my
Ok the error is showing up somewhere in this here code if($error==false) { $query

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.