部署后动态更改asp.net中web.config文件中的连接字符串 [英] Dynamically changing the connection string in web.config file in asp.net after deployment

查看:74
本文介绍了部署后动态更改asp.net中web.config文件中的连接字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI,



在我的asp.net应用程序中,首次启动应用程序时,如果没有提供数据库连接,它将重定向到单独的页面询问为了输入数据库的详细信息,如果它们提供有效的详细信息,我们必须创建新的数据库,并且需要在整个应用程序中使用该连接字符串。



这是我的方案是,在创建数据库后,我以编程方式将连接字符串存储在web.config文件中,但是当我尝试重用连接字符串时,它显示空字符串。



我知道web.config文件只给出了我们在编译时提供的值。为了克服这种情况,我使用XML文件来存储连接字符串,该字符串不受保护以存储安全和敏感信息。因为我的应用程序应该能够从前端更改连接字符串。



这里我的问题是:



1)有没有办法安全地存储连接字符串,如果从应用程序更改,则必须动态更改。



2)我可以访问我的XML文件通过浏览器,并且可以查看所有连接细节,我如何限制从URL访问XML文件。



和任何其他更好的解决方案表示赞赏。



谢谢



In my asp.net application , at first time launching the application, if there is no database connections provided ,it will redirect to separate page asks for entering the database details, if they provide valid details, we have to create the new database and need to use that connection string through out the application.

Here what my scenario is, after creating the database i stored the connection string in web.config file programatically, but when i trying to reuse the connection string it showing the empty string.

and i come to know that web.config file only gives the values what we provide at compile time. To overcome this situation i go for XML files to store connection string which is not secured to store the secured and sensitive information. Because my application should have the capability to change the connection string from front end.

here my questions are :

1 ) Is there any way to store the connection string securely,and that to have to change dynamically if change from the application.

2) I can access my XML file though browser, and can view all connection details, how can i restrict to access the XML file from the URL.

and any other better solution is appreciated.

Thanks

推荐答案

您可以加密数据并存储在 XML 文件或其他。



要限制对特定页面的访问,您可以在中添加配置设置的web.config 。请参阅 - 限制对在IIS7 / ASP.NET上运行的特定URL的访问 [ ^ ]
You can encrypt the data and store in XML file or something.

And to restrict the access to a specific page, you can add the configuration setting in your web.config. See - Restrict access to a specific URL, running on IIS7 / ASP.NET[^]


这篇关于部署后动态更改asp.net中web.config文件中的连接字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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