0
私は使用する従業員のIDを格納するempidという名前のクッキーを持っています。しかし、私はいつでもクッキーの値を取得しようとすると、その値は自動的にnullに設定され、このコードはページによって継承される部分クラスからのものです。 Request
オブジェクト、セットの発信クッキーではない - 私はクッキーが自動的に空になる
protected void Page_Load(object sender, EventArgs e)
{
using (SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["MyDbConn"].ToString()))
{
using (SqlCommand cmd = new SqlCommand())
{
try
{
cn.Open();
SqlDataReader conReader;
conReader = null;
mycomment.Text = Response.Cookies["empid"].Value;
// cmd.CommandText = "Select * from comments where c_from = " + Response.Cookies["cid"] + " and c_to = "+ Response.Cookies["empid"].ToString();
cmd.Connection = cn;
mycomment.Text = cmd.CommandText;
cmd.CommandType = CommandType.Text;
conReader = cmd.ExecuteReader();
while (conReader.Read())
{
mycomment.Text += conReader[3].ToString();
}
}
catch (Exception ex)
{
Console.Write(ex);
}
finally
{
cn.Close();
}
}
}
}