Storing and Reading Base64 Encoded Connection String in Web.Config

Many people store database connection string in web.config file. However, web.config file being an XML file, the data stored there is in clear text format. This is especially important for connection strings because anybody can easily see your database details including user id and password. In this article we will see how you can encrypt values stored in web.config using Base64 encoding and later on decrypt them in your code. Note that Base64 encoding is not a secure algorithm but it is a quick and easy way to hide the connection string details from casual readers.

http://www.dotnetbips.com/displayarticle.aspx?id=254
Author - Bipin Joshi
0
meghanjoshi
4/27/2004 4:39:00 AM
asp.net.announcements 2378 articles. 1 followers. Follow

0 Replies
845 Views

Similar Articles

[PageSpeed] 41
Get it on Google Play
Get it on Apple App Store

Reply:

Similar Artilces:

Can't read (connection) string from web.config with web matrix
Hi, I'm trying to retrieve a connection string from a web.config file and I get nothing back when I use ConfigurationSettings.AppSettings["ConnectionString"]; I set up a test stub called configtest.aspx to try to see what was wrong but I can't see where the problem is. I would really appreciate an extra pair of eyes here to help me solve this mystery cheers Jeet Here is my asp.net code <%@ Page Language="C#" %> <%@ import Namespace="System.Configuration" %> <script runat="server"> void Page_Load(Ob...

connection strings in web.config are read only
I'm trying to modify connection strings in the web.config from a web page, I get error "configuration is read only" (referencing system.configuration).  here's the code:<!-- Web.Config Configuration File --> <configuration><system.web> <customErrors mode="RemoteOnly" defaultRedirect="index.aspx"/><compilation debug="true"/></system.web> <connectionStrings> <add name="HS1ConnectionString" connectionString="Data Source=C:\Hydrosaver\Support\Programming\HS1.mdb;Persist Securit...

storing LDAP connection strings in web.config
What is the most convenient way to store username/password information of an LDAP connection in web.config? As far as I understand the LDAP connection string syntax does not support username / password (unlike in the SQL Server connection string), but this information must be stored elsewhere. One solution I've come up with is to store this information in appsettings, but I find this rather cumbersome (currently all information is stored in a database). What is the usual way to solve with this problem? Cheers,Roman  Hi r0x0r, You can store the information in web.config and encry...

how to read connection string form Web.config ?
Hi,   how to read connection string form Web.config ? in ASP.NET 2005 ?   regards,,,   You may try this: ConfigurationSettings.AppSettings.Get("ConnectionStringName")  This posting is provided "AS IS" with no warranties, and confers no rights. or ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();...

connection string in Web.Config file not being read
I have a problem with deploying my web site. I am using a connection string stored in the web.config file. I have tried to change the entry to reflect the location of the database on the server, but the changes are not reflected when running the site. Original Configuration Key: C:\OldKitchenNet\Kitchen.mdb New Configuration Key: <appSettings> <add key="con" value="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=D:\Databases\ResearchDB.mdb; Jet OLEDB:Database Locking Mode=0;" /> </appSettings> When I run the site it gi...

Updating Web.Config( ^SqlConnectionString^ was not found in web.config. Connection String was not updated).
hi ppl i installed the forum and when it was fininshed im not getting the fierst screen. when i wrote it myself on the explorer http://localhost/Forums it gave an error like this:::::::::::::::    Login failed for user 'amit'. Reason: Not associated with a trusted SQL Server connection Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'amit'. Reason:...

app.config connection string not being read
I have a Web app that has a UI Website Project and a DB dataset/db project. I am running SQL Server 2005 Express on my localhost for development purposes. I have the connectionstring for the DB in the DB projects app.config. The site is running perfectly on my localhost, but when I deploy the site to the review server and change the app.config's connectionstring accordingly a connection to the DB cannot be established. I then tried changing all the db names, usernames, password to jibberish in my app.config file on my localhost and running AND THE SITE STILL RAN ON LOCALHOST. For so...

storing two connection strings in a web.config file
Hi, I have to store two connection strings, one for excel sheet and one for database. Can I use two <add key, value> elements under appsettings ? When I try doing this I get an error. Thanks in advance, kmr Please post the error. You can have more than one key / value pair.Ryan OlshanASPInsider | Microsoft MVP, ASP.NEThttp://ryanolshan.comHow to ask a question I am getting the following error : Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuratio...

Is there another way to store connection string other than in web.config?
I knew how to store a connection string in web.config file so that easier to change server and database. Is there another way to store connection string other than in web.config? First of all, I'm curious as to why you don't want to store the string in the web.config?You could create a class extending the OleDbConnection (or whichever you're using) that creates the connection when the class is instanciated, then store the connection string as a private member of that class. The only problem with this approach is that you won't be able to use the class as a parameter in methods that call...

Cannot retrieve DB connection string stored in web.config
I’m an ASP.NET newbie. I’m trying to store my database connection string in 1 location and call that string in all the C# methods that access the database. I’ve stored my database connection string in my web.config file like this:   <appSettings>    <add key="NorthwindConnectionString2" value="Data Source=(local);Initial Catalog=Northwind;Integrated Security=SSPI;" />      </appSettings> In my .cs file, I have the following method that calls the DB connection string: protected ...

Help.... error when storing connection string in web.config file
I experience something strange when storing connection string in web.config file at home. In my asp.net web form, I declare my connection like this: myConn.ConnectionString=System.Configuration.ConfigurationSettings.AppSettings[ "dsn" ]; then in the web config file, I store the connection string like this: <appSettings> <add key="dsn" value="Server=localhost;UID=sa;PWD=sa;database=Pubs" /> </appSettings> When I tried to build and browse, it gives me error message: SQL Server does not exist or access denied. I...

how to store the connection string in the web.config file and use it from frontend?
I have a requirement like i have to store the connection string in the webconfig file instead of using again on each aspx page.How can i do it? hi    Check this  Web.config <?xml version="1.0" encoding="utf-8" ?> <!-- Web.Config Configuration File --> <configuration>   <appSettings>     <add key="ConnectionString"       value="server=localhost;database=Northwind;uid=sa;password=secret;" />   </appSettings> &nbs...

web.config/ADO.NET command/connection string problem?
Ok, I have searched everywhere and not been able to find an answer yet so I hope someone can help me. I have an application that uses a key in the web.config file to reference a connection string to SQL Server 2000. In the development environment, this works as expected. However, when I edit the web.config file to reference a new database (initial catalog) it doesn't seem to register for some of the command objects (based on stored procs). I will receive an error that the user could not log on to database X, even though the connection should now be referencing database Y. This only happens w...

Best way to use a connection string stored in my web.config
Hi All  I am learning about databases using VWD 2005 express and have a question please I am using access datasources to interact with my database but i do not want to have to update every page with the connection string each time i move my project, is there an easy way to get my datasource to look for a connectionstring stored in my web.config connection strings so i only need to change it once thanks gibbo <configuration>   <appSettings>      <add key="ConnectionString"         &n...

Web resources about - Storing and Reading Base64 Encoded Connection String in Web.Config - asp.net.announcements

Connection - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

iMedia Connection: Interactive Marketing News, Features, Podcasts and Video - iMediaConnection.com
If you send more email, you might make more money. Then again, you might destroy your reputation and revenue stream. Here's how to know what ...

HTTP persistent connection - Wikipedia, the free encyclopedia
... tacked on to an existing protocol. If the browser supports keep-alive, it adds an additional header to the request: Following this, the connection ...

MOTHER’S DAY: Facebook Examines Connections Between Moms, Kids
With Mother’s Day on the calendar this coming Sunday, Facebook examined the relationships between mothers and their children on the social network, ...

Complex Regional Pain Syndrome: CPRS researchers study auditory connection
For 16 years Kerry Whyman ``secretly&quot; thought she had bone cancer and was dying secretly because she'd stopped telling doctors how much ...

Fictional Lawyers Use Their Family Connections Too
This film character had a family connection to his lawyer.

The Direct Connection
... And the people reading my words respond back to me with words of their own. The technology that allows this is powerful but this direct connection ...

Is There A Connection Between Patrick Murphy's Over-The-Top Corruption And His Campaign Emails?
The DCCC may be stupid or even very stupid (as well as utterly incompetent) but their e-mail strategy is very well-planned out. Their overarching ...

CNN: Investigators Find ISIS Connection In San Bernardino Shooting
As the San Bernardino attack was happening, the female shooter, Tashfeen Malik posted on Facebook, pledging allegiance to ISIS leader Abu Bakr ...

Connection And Collaboration In the Cloud
Forbes technology editor Bruce Upbin deconstructs the cloud and maps its potential to your life.

Resources last updated: 12/8/2015 12:34:12 PM