高手进,,,ASP.NET ,Application和session对象问题!!!!!!!!!!!!!
请看这一段代码::::
using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
namespace 实验室设备管理系统
{
public class Global : System.Web.HttpApplication
{
private System.ComponentModel.IContainer components = null;
public Global()
{
InitializeComponent();
这是在Global.asax.cs里面的代码,运行时出现“上下文不存在InitializeComponent”,是怎么回事啊
我把这句话注释掉以后,在另一个接收页面出现
this.Lbllishi.Text = Application["total"].ToString();这句话出现黄色的标记
不能运行啊!!!!!!
this.Lblzaixian.Text = Application["online"].ToString();
}
protected void Application_start(object sender, EventArgs e)
{
SqlConnection con = DB.CreateConnection();
con.Open();
SqlCommand cmd = new SqlCommand("select * from countPeople", con);
int count = Convert.ToInt32(cmd.ExecuteScalar());
con.Close();
//Application["count"] = 0;
//ApplicationAdd("count", 0);
Application["total"] = count;
Application["online"] = 0;
}
protected void session_start(object sender, EventArgs e)
{
Session.Timeout = 1;
Application.Lock();
//Application["count"] = (int)Application["count"] + 1;
Application["total"] = (int)Application["total"] + 1;
Application["online"] = (int)Application["online"] + 1;
Application.UnLock();
}
protected void Application_BeginRequest(object sender, EventArgs e)
{
}
protected void Application_EndRequest(object sender, EventArgs e)
{
}
protected void Application_AuthenticateRequest(object sender, EventArgs e)
{
}
protected void Application_Error(object sender, EventArgs e)
{
}
protected void Session_End(object sender, EventArgs e)
{
Application.Lock();
Application["online"] = (int)Application["online"] -1;
Application.UnLock();
}
protected void Application_End(object sender, EventArgs e)
{
SqlConnection con = DB.CreateConnection();
con.Open();
SqlCommand cmd = new SqlCommand("update countPeople set num="+Application["count"].ToString(), con);
cmd.ExecuteNonQuery();
con.Close();
}