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());
}
}
在web.config中:ASP.net爲什麼我無法訪問此web.config密鑰?
<appSettings>
<!-- Website settings -->
<add key="BlogCommentsPerPage" value="3" />
我得到:
System.NullReferenceException: Object reference not set to an instance of an object.
在的Response.Write行