0

いつかC#とASPを使用してアプリケーションを作成しましたが、Cookieとは関係のない小さな変更を加えました。これは、IE用のCookieを作成するのではなく、Firefox用のCookieを作成します。

私の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 に答える