乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      Asp.net跨網(wǎng)站傳遞Session

       趨明 2012-02-16


      時間:2011-01-09 09:34來源:未知 作者:admin 點擊:44次
      -
      -
      基本思路:
      1 Session源網(wǎng)站設(shè)置Session數(shù)據(jù)同時,把SessionID和Session數(shù)據(jù)一起插入一個數(shù)據(jù)庫中,再把SessionID作為查詢字符串傳遞到Session獲取網(wǎng)站.
      2 Session獲取網(wǎng)站從數(shù)據(jù)庫中按SessionID查詢獲取Session數(shù)據(jù)并賦值到本網(wǎng)站的Session中.

      示例:
      Session源網(wǎng)站部分:


              private void Button1_Click(object sender, System.EventArgs e)
              {
                  try
                  {
                      this.TextBox1.Text = Session.SessionID;
                      Session["Name"] = this.TextBox2.Text;
                      Session["Role"] = this.TextBox3.Text;

                      OleDbConnection conn = new OleDbConnection( @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\webTest.mdb;Persist Security Info=False" );
                 
                      string strInsertSql = "insert into SessionData "
                          + " ( SessionID, SessionName, SessionRole ) "
                          + " values "
                          + "( '" + Session.SessionID + "', '" + Session["Name"] + "', '" +  Session["Role"] + "' )";
                     
                      conn.Open();
                      OleDbCommand cmd = new OleDbCommand( strInsertSql, conn );
                      cmd.ExecuteNonQuery();
                      conn.Close();

                      this.TextBox1.Text = "Session保存成功";

                      string strJumpUrl = "http://localhost/SessionReadFromOtherSite/ReadOtherSession.aspx?SessionId=" + Session.SessionID;

                      Response.Write("<script>window.open('" + strJumpUrl + "');</script>");
                  }
                  catch( System.Exception ex )
                  {
                      this.TextBox1.Text = ex.Message;
                  }       
              }
      Session獲取網(wǎng)站部分:


              private void Page_Load(object sender, System.EventArgs e)
              {
                  try
                  {
                      if ( Request.QueryString["SessionID"] != null )
                      {
                          OleDbConnection conn = new OleDbConnection( @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\webTest.mdb;Persist Security Info=False" );
                 
                          string strSql = "select "
                              + " SessionID, SessionName, SessionRole "
                              + " from SessionData "
                              + " where SessionID = '" + Request.QueryString["SessionID"].ToString() + "'";

                          OleDbDataAdapter da = new OleDbDataAdapter( strSql, conn );

                          DataSet ds = new DataSet();

                          da.Fill( ds );

                          Session["Name"] = ds.Tables[0].Rows[0]["SessionName"].ToString();
                          Session["Role"] = ds.Tables[0].Rows[0]["SessionRole"].ToString();

                          this.TextBox1.Text = ds.Tables[0].Rows[0]["SessionID"].ToString();
                          this.TextBox2.Text = Session["Name"].ToString();
                          this.TextBox3.Text = Session["Role"].ToString();
                      }
                  }
                  catch( System.Exception ex )
                  {
                      this.TextBox1.Text = ex.Message;
                  }
              }
       

      本篇文章來源于 www. 原文鏈接:http://www./html/aspnet/objects/2011/0109/3338.html

        本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
        轉(zhuǎn)藏 分享 獻花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多