这些方法都是在网上搜到的,现在只是临时写一下,过段时间再修改。 testA.aspx后台代码: using System; using System.Web; namespace WebApplication1 { public partial class testA : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { // PassValueByCookie(); // Response.Redirect("TestB.aspx"); // PassValeByContext(); PassValueByApplication(); Server.Transfer("TestB.aspx"); } /// <summary> /// 使用Server.Transfer方法 /// </summary> private void PassValueByRedirect() { Response.Redirect("TestB.aspx?A=b&AA=12&AAA=45"); } /// <summary> /// 使用Cookie对象变量 /// </summary> private void PassValueByCookie() { HttpCookie cookie_name = new HttpCookie("name"); cookie_name.Value = "12"; Response.AppendCookie(cookie_name); } /// <summary> /// Context /// </summary> public void PassValeByContext() { string Str = "Hello World"; this.Context.Items.Add("Text", Str); } /// <summary> /// 使用Application 对象变量 /// </summary> private void PassValueByApplication() { Application["name"] ="Hello!"; } public string Name { get { return Label1.Text; } } } } TestB.aspx后台代码: using System; namespace WebApplication1 { public partial class TestB : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { // GetValueByQueryString(); //GetValueByCookie(); // GetValueByPageFlow(); // GetValueByContext(); GetValueByApplication(); } /// <summary> /// /// </summary> private void GetValueByQueryString() { string a = Request.QueryString["A"].ToString(); string aa = Request.QueryString["AA"].ToString(); string aaa = Request.QueryString["AAA"].ToString(); } private void GetValueByCookie() { string name = Request.Cookies["name"].Value.ToString(); } private void GetValueByPageFlow() { testA newWeb= Context.Handler as testA;; //实例a窗体 string name; name = newWeb.Name; } private void GetValueByContext() { string a= this.Context.Items["Text"].ToString();//HttpContext接收数据 } private void GetValueByApplication() { string name; Application.Lock(); name = Application["name"].ToString(); Application.UnLock(); } } }