0

有时我用 C# 和 ASP 编写了一个应用程序,现在我做了一个与 cookie 无关的小改动,它不是为 IE 创建 cookie,而是为 Firefox 创建它们。

从我的 login.aspx:

            HttpCookie cLevel = new HttpCookie("Level");
            cLevel.Value = consulta.retornarNivel(Login2.UserName, Login2.Password).ToString();
            cNivel.Expires = DateTime.Now.AddMinutes(30);
            cNivel.Domain = Request.Url.Host.ToString();
            HttpCookie cUser = new HttpCookie("User");
            cUser.Value = Login2.UserName;
            cUser.Expires = DateTime.Now.AddMinutes(30);
            cUser.Domain = Request.Url.Host.ToString();


            //create cookies..
            Response.Cookies.Add(cLevel);
            Response.Cookies.Add(cUser);

            //redirect to Services
            Response.Redirect("Services.aspx");

现在对于我的 Services.aspx,在我的 page_load 上我有这一行:

    lbWelcome.Text = "Welcome" + Server.HtmlEncode(Request.Cookies["User"].Value);

IE 上的这一行给了我:对象引用未设置为对象的实例。在 Firefox 上,它可以完美解析。

什么可能会影响我的 FF 代码?

4

1 回答 1

0

Seting the cookies with the server's time is the worst way. if client got the different time, What do you think it will happen.

于 2012-09-14T08:34:10.827 回答