I am creating a verification page so that as my app moves from dev->qa->prod I can verify that all of the settings have been changed in web.config.
Looping over the connection strings and app settings was easy enough, but I'm struggling getting the information from a "custom" section. Specifically the elmah data.
I wrote this up which works, but it's such a hack job and I'm certain that there's a cleaner way.
Any suggestions?
string table = "<table border=\"1\"><tr><td colspan=\"2\">Elmah Information</td></tr>";
Hashtable security = (Hashtable)WebConfigurationManager.GetSection("elmah/security");
Hashtable email = (Hashtable)WebConfigurationManager.GetSection("elmah/errorMail");
Hashtable errorlog = (Hashtable)WebConfigurationManager.GetSection("elmah/errorLog");
table += "<tr><td>allowRemoteAccess</td><td>" + security["allowRemoteAccess"].ToString() + "</td></tr>";
table += "<tr><td>Error Log Type</td><td>" + errorlog["type"].ToString() + "</td></tr>";
table += "<tr><td>Error Log Path</td><td>" + errorlog["logPath"].ToString() + "</td></tr>";
table += "<tr><td>Email To</td><td>" + email["to"].ToString() + "</td></tr>";
table += "<tr><td>Email From</td><td>" + email["from"].ToString() + "</td></tr>";
table += "<tr><td>Email Subject</td><td>" + email["subject"].ToString() + "</td></tr>";
table += "<tr><td>Email SmtpServer</td><td>" + email["smtpServer"].ToString() + "</td></tr>";
table += "<tr><td>Email Async</td><td>" + email["async"].ToString() + "</td></tr></table>";
lblElmah.Text = table;