Home Database Mysql Tutorial 如何让您的ASP.NET数据库连接字符串是安全的

如何让您的ASP.NET数据库连接字符串是安全的

Jun 07, 2016 pm 05:54 PM
asp.net Safety database

今天午餐时候,我与 Rob Conery研究将This Developer's Life播客网站移动到 Git中。我们录制了整个升级和迁移经历,它很快会作为一个视频上传到TekPub上。 植入:在TekPub.tv上签出 我的 TekPub 秀源代码 。 在部署时出现了一个问题。我们将我们的数据库从SQ

今天午餐时候,我与 Rob Conery研究将This Developer's Life播客网站移动到 Git中。我们录制了整个升级和迁移经历,它很快会作为一个视频上传到TekPub上。

         植入:在TekPub.tv上签出。

在部署时出现了一个问题。我们将我们的从SQL Compact移动到了 Azure 中的 SQL Server 实例。但是,我们如何让我们的连接字符串是秘密的呢?我们将我们的源代码推送到 GitHub上,但不想公开我们的连接字符串和密码。

有时,你会制作一个 Web.Release.Config 文件,然后把它们放在那儿。有时你会制作一个 connectionStrings.config ,然后从 web.config 中引用它,但永远不会部署它。

然而,Azure 允许您将这些配置设置安全地保存在 Azure 中,所以它们永远不会以代码形式显示。请注意下面的屏幕截图。有一个名为"TDL."的连接字符串,它与我们在代码中所引用的名称和web.config 中连接字符串的名称是相匹配的。

如何让您的ASP.NET数据库连接字符串是安全的

我们的 ASP.NET Web Pages数据库调用是针对 WebMatrix.Data 中的 Database.Open。这是相当简单的。

var db = Database.Open("TDL");
Copy after login

这用于引用一个 TDL.sdf SQL Server Compact Edition (SQL CE) 文件。然后我们将它移到一个连接字符串中。

<connectionstrings><br>  <add name="TDL" connectionstring="blah blah" providername="yada yada"></add><br></connectionstrings>
Copy after login

如果您的 Azure 配置(请看上面的截图)拥有一个具有相同名称的值,当部署您的应用程序时,来自Azure 的安全值将被替换。

陷阱警告:我花了二十分钟试图找出为什么我的值没有得到更新。我的应用程序在操作时,好像根本就没有任何连接字符串值。我获得信息"找不到连接字符串"TDL""。多次气得咬牙切齿之后,我发现(多亏David Ebbo的帮助) 我把 元素放在web.config内的中了,而错误被吞没了。显然那一部分对元素是相当宽松的,它不理解- system.web部分当然更宽松了。无论如何,希望它可以节约一些访客 (也许是您!) 的时间,请确保您的 connectionStrings 元素位于

所有的一切,都运作得很好。

如何让您的ASP.NET数据库连接字符串是安全的

它让我们把代码放在 GitHub上,设置直接从 GitHub中自动部署到 Azure,同时仍让我们的 SQL 连接字符串 (和任何其他的产品设置) 是私密的。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1663
14
PHP Tutorial
1266
29
C# Tutorial
1239
24
iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos Jul 18, 2024 am 05:48 AM

Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps

Detailed tutorial on establishing a database connection using MySQLi in PHP Detailed tutorial on establishing a database connection using MySQLi in PHP Jun 04, 2024 pm 01:42 PM

How to use MySQLi to establish a database connection in PHP: Include MySQLi extension (require_once) Create connection function (functionconnect_to_db) Call connection function ($conn=connect_to_db()) Execute query ($result=$conn->query()) Close connection ( $conn->close())

How to handle database connection errors in PHP How to handle database connection errors in PHP Jun 05, 2024 pm 02:16 PM

To handle database connection errors in PHP, you can use the following steps: Use mysqli_connect_errno() to obtain the error code. Use mysqli_connect_error() to get the error message. By capturing and logging these error messages, database connection issues can be easily identified and resolved, ensuring the smooth running of your application.

How to use database callback functions in Golang? How to use database callback functions in Golang? Jun 03, 2024 pm 02:20 PM

Using the database callback function in Golang can achieve: executing custom code after the specified database operation is completed. Add custom behavior through separate functions without writing additional code. Callback functions are available for insert, update, delete, and query operations. You must use the sql.Exec, sql.QueryRow, or sql.Query function to use the callback function.

PHP Microframework: Security Discussion of Slim and Phalcon PHP Microframework: Security Discussion of Slim and Phalcon Jun 04, 2024 am 09:28 AM

In the security comparison between Slim and Phalcon in PHP micro-frameworks, Phalcon has built-in security features such as CSRF and XSS protection, form validation, etc., while Slim lacks out-of-the-box security features and requires manual implementation of security measures. For security-critical applications, Phalcon offers more comprehensive protection and is the better choice.

How to save JSON data to database in Golang? How to save JSON data to database in Golang? Jun 06, 2024 am 11:24 AM

JSON data can be saved into a MySQL database by using the gjson library or the json.Unmarshal function. The gjson library provides convenience methods to parse JSON fields, and the json.Unmarshal function requires a target type pointer to unmarshal JSON data. Both methods require preparing SQL statements and performing insert operations to persist the data into the database.

How should the Java framework security architecture design be balanced with business needs? How should the Java framework security architecture design be balanced with business needs? Jun 04, 2024 pm 02:53 PM

Java framework design enables security by balancing security needs with business needs: identifying key business needs and prioritizing relevant security requirements. Develop flexible security strategies, respond to threats in layers, and make regular adjustments. Consider architectural flexibility, support business evolution, and abstract security functions. Prioritize efficiency and availability, optimize security measures, and improve visibility.

Which wallet is safer for SHIB coins? (Must read for newbies) Which wallet is safer for SHIB coins? (Must read for newbies) Jun 05, 2024 pm 01:30 PM

SHIB coin is no longer unfamiliar to investors. It is a conceptual token of the same type as Dogecoin. With the development of the market, SHIB’s current market value has ranked 12th. It can be seen that the SHIB market is hot and attracts countless investments. investors participate in investment. In the past, there have been frequent transactions and wallet security incidents in the market. Many investors have been worried about the storage problem of SHIB. They wonder which wallet is safer for SHIB coins at the moment? According to market data analysis, the relatively safe wallets are mainly OKXWeb3Wallet, imToken, and MetaMask wallets, which will be relatively safe. Next, the editor will talk about them in detail. Which wallet is safer for SHIB coins? At present, SHIB coins are placed on OKXWe

See all articles