0
protected void Button_Click(object sender, CommandEventArgs e)
        {
            Response.Redirect("EnterSession.aspx?session=" + e.CommandArgument.ToString());
        }

上記のコードは、session_id をクエリ文字列として EnterSession.aspx に渡します。

EnterSession.aspx に次の c# 関連コードがあります。

protected string _SessionName = null;
        public string SessionName;
        public string sessionId
        {
            get
            {
                if (null == _SessionName)
                {
                    SqlConnection thisConnection = new SqlConnection(@"data Source=sorce");
                    {
                        thisConnection.Open();
                        SqlCommand thisCommand = thisConnection.CreateCommand();
                        thisCommand.CommandText = " SELECT session_name FROM myapp_Session WHERE session_id = @SessionId;";
                        {
                            thisCommand.Parameters.AddWithValue("sessionId", sessionId);
                            SqlDataReader thisReader = thisCommand.ExecuteReader();

                            thisCommand.Parameters["@SessionId"].Value = Convert.ToInt32(Request.QueryString["session"]);

                            using (var reader = thisCommand.ExecuteReader())
                            {
                                if (reader.Read())
                                {
                                    _SessionName = reader.GetString(0);
                                }
                                else
                                {
                                    throw new ArgumentException("Invalid session id");
                                }
                            }
                        }
                    }
                }
                return _SessionName;
            }
        }

EnterSession.aspx で、このコードを使用して session_name を GA に渡しました

_gaq.push(['pageTrackerTime._trackEvent', document.getElementById('session_name').value, 'test', document.location.href, roundleaveSiteEnd]);

そして、このコードを EnterSession.aspx ページにも含めます

 <input type="hidden" id="session_name" />
<script type="text/javascript">
    document.getElementById('session_name').value = '<%= this.SessionName %>';
</script>

現在、GA サーバーに渡された session_name が見つかりません。

どこで間違いを犯したか誰か教えてくれませんか..ありがとう

4

0 に答える 0