Click here to Skip to main content
12,815,592 members (41,053 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


3 bookmarked
Posted 14 May 2010

Basic Example of On-The-Fly Config Section Encryption

, 14 May 2010 CPOL
Rate this:
Please Sign up or sign in to vote.
Basic Example of On-The-Fly Config Section Encryption

I recently answered a question about how you could securely modify a value within an encrypted configuration website without having to create a duplicate config file. Well, the answer’s pretty simple and straightforward – just use the API!

A quick example page could be:   

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" 
Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
<html xmlns="">
<head runat="server">
 <form id="form1" runat="server">
     <asp:Button ID="EncryptButton" runat="server" Text="Encrypt" 
	OnClick="EncryptButton_Click" />
     <asp:Button ID="DecryptButton" runat="server" Text="Decrypt" 
	OnClick="DecryptButton_Click" />
     <asp:Button ID="IncrementButton" runat="server" Text="Increment" 
	OnClick="IncrementButton_Click" />
     <asp:Label ID="CountLabel" runat="server" Text="0"></asp:Label>
     <br />
     <asp:Label ID="StatusLabel" runat="server" Text="" 
using System;
using System.Configuration;
using System.Linq;
using System.Web.Configuration;

public partial class _Default : System.Web.UI.Page
 /// <span class="code-SummaryComment"><summary>



This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Martin Jarvis
Software Developer (Senior) Freestyle Interactive Ltd
United Kingdom United Kingdom
I'm a lead developer for Freestyle Interactive Ltd where we create many wonderful websites built on Microsofts ASP.Net and Ektron CMS.

I've been developing .Net applications (both Windows and Web) since 2002.

You may also be interested in...

Comments and Discussions

Generallet IIS do the work Pin
Bob Crowley18-May-10 11:29
memberBob Crowley18-May-10 11:29 
GeneralRe: let IIS do the work Pin
Martin Jarvis18-May-10 11:51
memberMartin Jarvis18-May-10 11:51 
GeneralRe: let IIS do the work Pin
Bob Crowley19-May-10 3:10
memberBob Crowley19-May-10 3:10 
GeneralRe: let IIS do the work Pin
Martin Jarvis19-May-10 3:41
memberMartin Jarvis19-May-10 3:41 
GeneralWep App restart Pin
abhidhar17-May-10 19:54
memberabhidhar17-May-10 19:54 
GeneralRe: Wep App restart Pin
Martin Jarvis18-May-10 11:53
memberMartin Jarvis18-May-10 11:53 
GeneralRe: Wep App restart Pin
abhidhar18-May-10 19:58
memberabhidhar18-May-10 19:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170308.1 | Last Updated 14 May 2010
Article Copyright 2010 by Martin Jarvis
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid