public partial class MasterPages_Main : System.Web.UI.MasterPage
{
public string TopMenuTab;
public string SubMenuTab;
public Configuration Config = WebConfigurationManager.OpenWebConfiguration(null);
protected void Page_Load(object sender, EventArgs e)
{
ContentMenu.TopTabSelected = TopMenuTab;
ContentMenu.SubTabSelected = SubMenuTab;
Response.Write("K" + Config.AppSettings.Settings["BlogCommentsPerPage"].ToString());
}
}
In web.config:
<appSettings>
<!-- Website settings -->
<add key="BlogCommentsPerPage" value="3" />
I get:
System.NullReferenceException: Object reference not set to an instance of an object.
On the response.write line
do a null check and then call
ToString()orConvert.ToInt32()