修改Web配置文件中的连接字符串后,无法登录到系统. [英] cannot log to the system after modifing the connection string in the web config file.
本文介绍了修改Web配置文件中的连接字符串后,无法登录到系统.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
foreach (var cString in conectionstring)
{
conectionString = cString;
Configuration openWebConfiguration =WebConfigurationManager.OpenWebConfiguration("~");
ConnectionStringsSection sections = openWebConfiguration.GetSection("connectionStrings") as ConnectionStringsSection;
if (sections != null)
{
sections.ConnectionStrings["GihanBConnectionString"].ConnectionString = conectionString;
ConfigurationManager.RefreshSection("connectionStrings");
openWebConfiguration.Save();
//Page.Response.Redirect(Page.Request.Url.ToString(), false);
//Response.Redirect(Request.Url.ToString());
}
}
朋友,
我已经使用此代码在运行时更改了我的连接字符串.它的工作原理.但是问题是,在修改之后,我无法进入系统.可以这样做吗?
我的目的是在运行时为我的asp.net Web应用程序选择数据库.(一个Web应用程序的多个数据库).如果有人可以帮助我,那么这对我非常有用.
谢谢.
hi friends,
i have used this code to change my connection string at run time.its working.but the problem is,after modify, i cannot enter to the system.is it possible to do?
my purpose is to select database at run time for my asp.net web application.(multiple database for a web application).if some one can help me for this it will great for me.
thank you.
推荐答案
请参见以下链接:
http://forums.asp.net/p/1364021/2829515.aspx [ ^ ]
http://csharpdotnetfreak.blogspot.com/2011/12/write-modify-webconfig- programmatically.html [ ^ ]
See below links:
http://forums.asp.net/p/1364021/2829515.aspx[^]
http://csharpdotnetfreak.blogspot.com/2011/12/write-modify-webconfig-programmatically.html[^]
这篇关于修改Web配置文件中的连接字符串后,无法登录到系统.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文