Results 1 to 3 of 3

Thread: Encrypting web.config files

  1. #1
    Join Date
    Dec 2007
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Encrypting web.config files

    Hi.

    I've been trying to encrypt the AppSettings section of the Web.Config file using the following code in the Application_Start event-handler, but it generates an exception. Is my code correct, or is it some other problem (e.g. my app doesn't have permission to modify its own config file).
    Code:
    Configuration config = WebConfigurationManager.OpenWebConfiguration(null);
    SectionInformation secInfo = config.GetSection("appSettings").SectionInformation;
    if (!secInfo.IsProtected)
    {
             secInfo.ProtectSection("DataProtectionConfigurationProvider");
             secInfo.ForceSave = true;
             config.Save();
    }
    Is there some other way of achieving this?

    Best wishes,
    Simon.

  2. #2
    Join Date
    Apr 2005
    Location
    Haslemere, Surrey, UK
    Posts
    338
    Thanks
    5
    Thanked 3 Times in 3 Posts

    Default

    Funnily enough I have been looking at the very same issue of encrypting the config file.

    I believe it cannot be done as the RFH servers run in Medium Trust and need to be Full Trust to do what you are after.

    I am sure someone will either back me up on this (or shoot me down with a solution - to which I too would be grateful).

    Alastair - WOWD



  3. #3
    Join Date
    Jan 2006
    Posts
    419
    Thanks
    2
    Thanked 16 Times in 16 Posts

    Default

    I reckon it will work in shared env

    http://www.developerfusion.com/code/...-in-aspnet-20/

    http://weblogs.asp.net/scottgu/archi...09/434893.aspx

    Have never done it though but know of many paranoid people who appreciate the functionality

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Encrypting web form information
    By UKFlyer in forum Customer Feedback and Suggestions
    Replies: 2
    Last Post: 1st March 2008, 02:48 AM
  2. Complex problem with multiple web site under same web (for Warren)
    By Warren Ashcroft in forum General Technical Support
    Replies: 1
    Last Post: 19th October 2006, 11:58 AM
  3. web.config question
    By theonlinecleaningshop in forum Technical Support
    Replies: 4
    Last Post: 15th March 2006, 11:09 AM
  4. Remember to edit Web.Config when using VS2005
    By jaimalchohan in forum Technical Support
    Replies: 3
    Last Post: 9th November 2005, 01:16 PM
  5. web.config and aythentication error
    By jaimalchohan in forum ASP.NET
    Replies: 3
    Last Post: 24th October 2005, 04:42 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •