1、Global.asax文件:
void Application_Start(object sender, EventArgs e)
{
// 在應用程序啟動時運行的代碼
//載入配置文檔
XmlDocument AppConfig = new XmlDocument();
AppConfig.Load(HttpContext.Current.Server.MapPath("~/AppConfig.xml"));
//讀取配置信息
XmlNode xnList = AppConfig.GetElementsByTagName("dblist")[0];
XmlElement xeDb1 = (XmlElement)xnList.ChildNodes[0];
XmlElement xeDb2 = (XmlElement)xnList.ChildNodes[1];
Application["db1user"] = xeDb1.GetAttribute("user");
Application["db1source"] = xeDb1.GetAttribute("source");
Application["db2user"] = xeDb2.GetAttribute("user");
Application["db2source"] = xeDb2.GetAttribute("source");
Application["count"] = 0;
}
void Application_End(object sender, EventArgs e)
{
//在應用程序關閉時運行的代碼
}
void Application_Error(object sender, EventArgs e)
{
//在出現未處理的錯誤時運行的代碼
}
void Session_Start(object sender, EventArgs e)
{
//在新會話啟動時運行的代碼
Application["count"] = Convert.ToInt32(Application["count"])+1;
}
void Session_End(object sender, EventArgs e)
{
//在會話結束時運行的代碼。
// 注意: 只有在 Web.config 文件中的 sessionstate 模式設置為
// InProc 時,才會引發 Session_End 事件。如果會話模式
//設置為 StateServer 或 SQLServer,則不會引發該事件。
Application["count"] = Convert.ToInt32(Application["count"]) - 1;
}
</script
2、顯示頁面:
前臺:
后臺:
新聞熱點
疑難解答