为什么读不到Cookies的值??
if (this.txtname.Text == "" || this.txtmobile.Text == "")
{
Response.Write("<script>");
Response.Write("alert('请输入您的姓名和手机号码!')");
Response.Write("</script>");
Response.Write("<script>window.location.replace('login.aspx')</script>");
}
HttpCookie readcookie = System.Web.HttpContext.Current.Request.Cookies["Username"];
HttpCookie readcookiemobile = System.Web.HttpContext.Current.Request.Cookies["Usermobile"];
HttpCookie readcookieid = System.Web.HttpContext.Current.Request.Cookies["Userid"];
if (!Object.Equals(readcookie, null) && !Object.Equals(readcookiemobile, null))
{
//HttpCookie readcookie = Request.Cookies["Username"];
//HttpCookie readcookiemobile = Request.Cookies["Usermobile"];
//HttpCookie readcookieid = Request.Cookies["Userid"];
string name = this.txtname.Text.Trim();
string mobile = this.txtmobile.Text.Trim();
if ((name == readcookie.Value) && (mobile == readcookiemobile.Value))
{
Session["id"] = readcookieid.Value;
Session["name"] = readcookie.Value;
Session.Timeout = 24 * 60;
Response.Write("<script>window.location.replace('singleExam.aspx?type=1')</script>");
}
else
{
Response.Write("<script>");
Response.Write("alert('系统未搜索到您的有效信息,请重新核对!')");
Response.Write("</script>");
Response.Write("<script>window.location.replace('login.aspx')</script>");
}
}
else
{
Response.Write("<script>alert(readcookie.Value)</script>");
}
这样的代码没有错吧,怎么取不到Cookies的值,在本地是好的,在服务器上就是读不到值,难道是Username是中文的有关???