System.Web.HttpContext.Current.Request.Cookies["UserID"].Value

解决方案 »

  1.   

    [C#]string uid = "";
    try{
       uid = Request.Cookies["UserID"].Value;
    }
    catch{
       uid = "";
    }
      

  2.   

    protected void Page_Load(Object sender, EventArgs e)
    {
    bool logintrue;
    string user_id,password;
    if(!Page.IsPostBack)
    {
    user_id=Request.Form["user_id"];
    password=Request.Form["password"];
    bbsname.Text=con.bbsname;
    if(user_id!=null&&password!=null)
    {
    con.open();
    logintrue=con.checklogin(user_id,password);
    con.link.Close();
    if(logintrue)
    {
    Response.Redirect("index.aspx");
    }
    else
    {
    wc.Visible=true;
    wc.InnerHtml="用户名或口令不对";
    }
    }
    }

    } protected void login(Object sender, EventArgs e)
    {
    bool logintrue;
    con.open();
    logintrue=con.checklogin(user_id.Text,password.Text);
    con.link.Close();
    if(logintrue)
    {
    string savedate=savepassword.SelectedItem.Value;
    if(Int32.Parse(savedate)>0)
    {
    HttpCookie cookie=new HttpCookie("aspx");
    cookie["user_id"]=user_id.Text;
    cookie["savepassword"]=savedate;
    cookie["password"]=password.Text;;
    cookie.Expires=DateTime.Now.AddDays(Int32.Parse(savedate));
    Response.Cookies.Add(cookie);
    }
    Response.Redirect("index.aspx");
    }
    else
    {
    wc.Visible=true;
    wc.InnerHtml="用户名或口令不对";
    }

    }
      

  3.   

    。NET是很讨厌,和ASP差远了----------------
    !??呵呵
      

  4.   

    。NET是很讨厌,和ASP差远了----------------
    !??呵呵
    ----------------
    hehe!
      

  5.   

    在.net中一定要注意[]和()的使用,
    有很多地方与asp不一样,
    我刚开始的时候也总是犯这种错误,
    习惯就好了,
    其实.net比asp好多了。