How to make your ASP. NET database connection strings safe

Source: Internet
Author: User
At lunch today, I studied with RobConery to move the ThisDevelopersLife podcast website to Git. We recorded the entire upgrade and migration experience, which will soon be uploaded to TekPub as a video. Implant: Check out my TekPub source code on TekPub. TV. A problem occurred during deployment. We extract our database from SQ

At lunch today, Rob Conery and I studied moving This Developer's Life podcast website to Git. We recorded the entire upgrade and migration experience, which will soon be uploaded to TekPub as a video. Implant: Check out my TekPub source code on TekPub. TV. A problem occurred during deployment. We extract our database from SQ

At lunch today, Rob Conery and I studied moving This Developer's Life podcast website to Git. We recorded the entire upgrade and migration experience, which will soon be uploaded to TekPub as a video.

Implant: Check out on TekPub. TV.

A problem occurred during deployment. We moved our SQL Compact to the SQL Server instance in Azure. But how can we keep our connection strings confidential? We push our source code to GitHub, but do not want to disclose our connection strings and passwords.

Sometimes, you create a Web. Release. Config file and place it there. Sometimes you create a connectionStrings. config and reference it from web. config, but it will never be deployed.

However, Azure allows you to securely store these configuration settings in Azure, so they will never be displayed as code. Pay attention to the following screen. There is a connection string named "TDL.", which matches the name referenced in the Code and the name of the connection string in web. config.

Our ASP. NET Web Pages Database is called for Database. Open in WebMatrix. Data. This is quite simple.

var db = Database.Open("TDL");

This is used to reference a tdl. sdf SQL Server Compact Edition (SQL CE) file. Then we move it to a connection string.

 
  

If your Azure configuration (see the above) has a value with the same name, the security value from Azure will be replaced when your application is deployed.

Trap warning: It took me 20 minutes to figure out why my value was not updated. When my application is operating, it seems that there is no connection string value at all. I got the information "cannot find the connection string" TDL "". After several gritted teeth, I found that (thanks to the help of David Ebbo) Elements placed in web. config Errors are swallowed up. Obviously, that part is quite loose to the element, and it does not understand-the system. web part is certainly loose. In any case, we hope it will save some visitors (maybe you !) Make sure that your connectionStrings element is located in Lower

Everything works well.

It allows us to put code on GitHub, And the settings are automatically deployed directly from GitHub to Azure, while still making our SQL connection strings (and any other product settings) private.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.