我应该在哪里存储我的asp.net-5应用程序的生产环境的连接字符串? [英] Where should I store the connection string for the production environment of my asp.net-5 app?

查看:161
本文介绍了我应该在哪里存储我的asp.net-5应用程序的生产环境的连接字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在部署到IIS 7(不是Azure)时,生产和登台连接字符串应该存储在asp.net-5应用程序中的哪个位置?

Where should the production and staging connection strings be stored in an asp.net-5 application, when deploying into IIS 7 (not Azure) ?

我正在寻找对于推荐的做法/最佳做法,特别是安全性。

I am looking for the recommended way of doing it / best-practice, especially security-wise.

推荐答案

在ASP.NET 5中,它可以指定多个配置源。由于对先前模型的这一欢迎更改,您可以将开发连接字符串存储在简单的json文件中,并将环境变量中的登台和生产连接字符串直接存储在相应的服务器上。

In ASP.NET 5 it's possible to specify multiple configuration sources. Thanks to this welcoming change to previous model you can store your development connection string in simple json file, and your staging and production connection string in environment variables directly on the respective servers.

如果你像这样配置你的应用程序:

If you configure your app like this :

var config = new Configuration()
.AddJsonFile("config.json")
.AddEnvironmentVariables();

并且config.json和环境变量都有连接字符串,然后环境源将获胜。

and there is connection string in both config.json and environment variable then environment source will win.

因此,将您的开发连接字符串存储在config.json中(并在源代码管理中自由签入)并在环境变量中生成一个。更多信息此处此处

So, store your development connection string in config.json(and freely check in in source control) and production one in environment variable. More info here and here.

这篇关于我应该在哪里存储我的asp.net-5应用程序的生产环境的连接字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆