Discuz!NT官方社区

首页 » Discuz!NT交流与讨论 » BUG 反馈 » [整合]获取用户名出错
chy710 - 2008-6-26 11:21:00
protected void Page_Init(object sender, EventArgs e)
    {
        HttpCookie cookie = Request.Cookies["dnt"];
        if (cookie != null)
        {
            string username = null;
            if (cookie.Values["userName"] == null)
            {
                username = Users.GetUserName(int.Parse(cookie.Values["userid"].ToString()));
                cookie.Values["userName"] = Server.HtmlEncode(username);
            }
            else
                username = cookie.Values["userName"].ToString();

            //...
        }
    }

上面红色一句出错,提示Object reference not set to an instance of an object.
chy710 - 2008-6-26 11:24:00
不明白,dnt的cookie里为什么不存用户名,密码都存了,还不存用户名?
1
查看完整版本: [整合]获取用户名出错