Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
1
Answer
how to get server name in microfocus and use the web config
Anand Kannan
10y
1.2k
1
Reply
I am trying to get the server name in microfocus asp.net and use the same to invoke the connection string from web config.
This is what we do in asp.net - is there a analogous syntax in Microfocus -
<appSettings>
<add key="devconn" value="Data Source=XX\YY;Initial Catalog=XXXTEST;Persist Security Info=True;User ID=XXXWEB;Password=12345678"/>
</appsettings>
if (HttpContext.Current.Request != null){
strSvrName = HttpContext.Current.Request.ServerVariables["SERVER_NAME"].ToString();
}
switch (strSvrName.ToUpper())
{
case "LOCALHOST":
case "XXXDEV.WEB.XXX.COM":
string strDbConn = ConfigurationManager.AppSettings["devconn"];
break;
case "XXXTST.WEB.XXX.COM":
string strDbConn = ConfigurationManager.AppSettings["testconn"];
break;
case "XXXPRE.WEB.XXX.COM":
string strDbConn = ConfigurationManager.AppSettings["prodconn"];
break;
case "XXX.WEB.XXX.COM":
break;
}
Thanks
Anand
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
how to display watch on asp.net pages
Bulk update in mvc