我是这样做的阿 /Dim MyCookie As New HttpCookie("MyCookie")
MyCookie.Value = Session("UserName")
Response.Cookies.Add(MyCookie)
             '后改动2003/07/08
FormsAuthentication.SetAuthCookie(Session("UserName"), True)/////////////////////////////////////////////tbUser.text=Context.User.Identity.Name
谁能说点正事啊 /////////////////////////////

解决方案 »

  1.   

    验证模式应设置为“Forms”:
    <authentication mode="Forms">
    <forms name="YourAuthName" loginUrl="Login.aspx" 
    protection="All" path="/"></forms>
    </authentication>
      

  2.   

    保存Cookie:
    this.cookie = new HttpCookie("test");
    this.cookie.Values.Add("loginid", this.txtloginid.Text);
    this.cookie.Expires = DateTime.MaxValue;
    base.Response.AppendCookie(this.cookie);取出Cookie并赋值给用户文本框做为默认值:
    this.cookie = this.Request.Cookies["test"];
    this.txtloginid.Text = this.cookie.Values["loginid"];楼主保存了Cookie,但你并没有把Cookie取出赋值给文本框啊。
      

  3.   

    用户登录成功后保存登录名到Cookie里:
    this.cookie = new HttpCookie("MyCookie");
    this.cookie.Values.Add("UserName", this.tbUser.Text);
    this.cookie.Expires = DateTime.MaxValue;
    base.Response.AppendCookie(this.cookie);在Page_Load事件里取出Cookie赋值
    if (this.Request.Cookies["MyCookie"] != null) 
    {
      this.cookie = this.Request.Cookies["MyCookie"];
      this.tbUser.Text = this.cookie.Values["UserName"];
    }