Loading user information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading user information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

Encrypting your web.config file with ASP 2.0 (Visual Studio 2005)


Right click “Save as…”

Federal Developer Evangelist, Robert Shelton, Jr., takes you through a short (8 minute) demonstration of how Encrypt portions of your web.config with ASP 2.0 (Visual Studio 2005).  This walkthrough shows you how to encrypt two sections of your web.config (AppSettings and ConnectionStrings) with the DPAPI (DataProtectionConfigurationProvider).  In addition to these two sections, you can also encrypt your Identity and SessionState sections.



My blog URL: http://sheltonblog.com 


Channel 9 Article: Encrypt Configuration Sections in ASP.NET 2.0 Using RSA

MSDN Article: How To: Encrypt Configuration Sections in ASP.NET 2.0 Using DPAPI

Please check out some of my other screencast by clicking this search link.  Including a 3 part series on programming Active Directory with Visual Studio 2005.


~ Robert Shelton, Jr.


Follow the discussion

  • Oops, something didn't work.

    Getting subscription
    Subscribe to this conversation
  • Luciano Evaristo GuercheguercheLE guerchele
    Dear Robert Shelton, Jr.,

    If I encrypt a web.config file using aspnet_regiis.exe with -pe or -pef option, get encrypted web.config file and take it to another machine, run aspnet_regiis.exe with -pd or -pdf option, what do I get? A plain file or an error? Do the encryption algorithm uses the PKI or any salt to encrypt so that if you exchange windows accounts or machine, the user does not get to the plain file?
  • I'm not sure if I fully understand your question, but I would say this: Since the Web.config is a server-based file, the user shouldn't see anything in the way of errors.  In fact, what you have to do, is when you get to the server(s) that you are going to run the web application on, you would encrypt the file at that server(s), so that the key was stored on that server.

    I hope that this is clearer,

  • jrsjrs
    This was a nice demo Robert.

    I'm curous it you have to encrypt the config files for every separate installation of the webapp (like you did in the video). I guess the encryption/decryption depends on some machine specific key.

    How about web application farms. Is there a way to encrypt the config file once and deploy the decrypted version to all instances in the farm?


    Johan Sundström
  • Very informative.  However, what the significance of the "configProtectionProvider" attribute not being defined and the error associated with the "EncryptedData" tag in your Screencast.  Should they just be ignored?
  • I have tried this command with failed results:

    C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -pef "connectionStrings" "C:\MyFolder\EncryptionDemo" –prov "DataProtectionConfigurationProvider"

    All I got after attempting to run this command from a windows cmd prompt was the aspnet_regiis help screen.  What am I missing?  I have even ensured my web.config file is not read only and that the aspnet user has full control on the security permissions.  Please help.  Thanks you.


    Ron Breeding Sad

  • cloak13PLAGUEcloak13​PLAGUE Greatest Video Game Ever!
    Thanks very much for the demo. I would like to hit on the question that the one user earlier asked. I think what the user was asking is if some how some one were able to retrieve that web config file could they take it to another machine and run the decrypt on it and get the information out of the file?

    For example, Johnny Cracker steals the web.config file from my site some how. Could they run -pd on their home IIS 6 server and decrypt the file exposing the information we are trying to hide?

    Another possible scenario is that I have a web farm. If server A which I encrypted the file on dies can I decrypt the file on server B?

    Just curious,
    Thanks again for posting!

    Tim Kulp

Remove this comment

Remove this thread


Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.