Get ConnectionStringsSection part of your configuration : ConnectionStringsSection « Configuration « ASP.NET Tutorial






<%@ page language="C#" %>
 <%@ import namespace="System.Web.Management" %>

<script runat="server">
    
void Page_Load(object sender, System.EventArgs e)
{
    string appPath = this.Request.ApplicationPath;    

    Configuration config = Configuration.GetConfigurationForUrl(appPath);

    ConnectionStringsSection connStrings = (ConnectionStringsSection) config.Sections["connectionStrings"];

    foreach(ConnectionStringSettings connString in connStrings.ConnectionStrings) {
        this.Response.Write(string.Format("<b>{0}</b> = {1}", connString.Name, connString.ConnectionString));
    }
}
    
</script>

<html>
<head id="Head1" runat="server">
    <title>Untitled Page</title>
</head>
    
<body>
    <form id="Form1" runat="server">
    </form>
</body>
</html>








16.15.ConnectionStringsSection
16.15.1.Get ConnectionStringsSection part of your configuration