在程序中写代码如,session["name"]=null则后面就你应该知道了这不用说了

解决方案 »

  1.   

    在WebConfig中配置应用程序为 Form验证方式。
      

  2.   

    可以写个user类,用其判断方便。
      

  3.   

    使用cookie,给你点代码:
    登录时:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            If 条件满足 Then
                Dim aCookie As New HttpCookie("userinfo")
                aCookie.Values("userName") = TextBox1.Text
                aCookie.Values("userpwd") = TextBox2.Text
                aCookie.Expires = DateTime.Now.AddDays(500)
                Response.Cookies.Add(aCookie)
                Response.Redirect("tptj.aspx")
            Else
                Label3.Visible = True
                Label3.Text = "用户名或密码输入错误!"
            End If
        End Sub是第二个页面:
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       If Request.Cookies("olsy") Is Nothing Then
                Response.Redirect("登录页面")
           Else
               继续
        end if
      

  4.   

    private void Page_Load(object sender, System.EventArgs e)
    {
    // 在此处放置用户代码以初始化页面
    if(Session["User_id"]==null)
    Response.Redirect("logon.aspx");
    else
    Response.Redirect("index.aspx")

    }
    Session["User_id"]保存用户名,在用户成功登录后,你把用户名赋给它就行了
    logon.aspx      //登录页面
    index.aspx      //系统页面
      

  5.   

    同意dream2001(飞云) 的说法,
    也可以使用session,用法一样。
      

  6.   

    在需要登陆后才能查看 的页面的Page_load中加入Session判断,如果session["uid"]==null 则redirect to login 页面
      

  7.   

    Session.add放在哪里?是Global.asax中的session_start中还是的click中,然后取消session呢?在哪里?谢谢