做论坛这样的系统,如何进行用户验证?Authorization
给个例子好吗?多谢多谢

解决方案 »

  1.   

    session!!
    private void Page_Load(object sender, System.EventArgs e)
    {
    if(!IsPostBack)
    {
    if(Session==null)
    {
    Response.Redirect(PageBase.UrlBase+"/index.htm");
    }

        
    }
    }
      

  2.   

    http://dev.csdn.net/develop/article/18/18958.shtm
      

  3.   

    用 form验证,
    http://blog.csdn.net/happyjun2000/archive/2004/09/03/93376.aspx
    其实用自己写入session来验证也行了
      

  4.   

    论坛一般都用session验证,这样可以省去不少的麻烦。登陆后把用户信息放在session里,然后每个页面判断
    private void Page_Load(object sender, System.EventArgs e)
    {
    if(!IsPostBack)
    {
    if(Session==null)
    {
    Response.Redirect("error.htm");
    }

        
    }
    }
      

  5.   

    webconfig:
     <authentication mode="Forms">
        <forms  name="fda" loginUrl="login.aspx">
        <credentials passwordFormat="Clear">
        </credentials>
        </forms> 
    </authentication>
           <authorization>
             <deny users="?"/> 
                 </authorization>
      

  6.   

    Private Function CreateAuthTicket(ByVal userName As String, ByVal roles As String, _
            ByVal persistent As Boolean) As FormsAuthenticationTicket
            Return New FormsAuthenticationTicket(1, userName, DateTime.Now, _
                DateTime.Now.AddMinutes(60), persistent, roles)
        End Function    
        Private Function CreateAuthCookie(ByVal authTicket As FormsAuthenticationTicket) As HttpCookie
            Return New HttpCookie(FormsAuthentication.FormsCookieName, _
                FormsAuthentication.Encrypt(authTicket))
        End Function
    Dim returnUrl As String                               
      Dim authTicket As FormsAuthenticationTicket     
            Dim authCookie As HttpCookie                    authTicket = CreateAuthTicket(txtUserID.Text, CStr(viewstate("roles")), False)
                            authCookie = CreateAuthCookie(authTicket)
                            HttpContext.Current.Response.Cookies.Add(authCookie)
                If Request("ReturnUrl") Is Nothing Then
                    Response.Redirect("Menu.aspx")
                Else
                    Response.Redirect(Request("ReturnUrl"))
                End If
      

  7.   

    还是不明白<authentication mode="Forms">
        <forms  name="fda" loginUrl="login.aspx">
        <credentials passwordFormat="Clear">
        </credentials>
        </forms> 
    </authentication>
           <authorization>
             <deny users="?"/> 
                 </authorization>
      

  8.   

    论坛的用户管理一般涉及两个层次:用户是否在本论坛注册了,二,用户的权限管理。其实这又可以归结为一个问题,即用户的权限问题,即使没有注册的“观光客”也可给他比较低的权限,所以论坛的用户管理的核心还是用户的权限管理,如何给用户权限(一般除了静态的直接赋予一个客户权限以外还可以动态的随着用户的某一项记录值的增加而变动权限),这个问题解决了接下来实现比较简单,在用户登陆的时候,在COOKIES中记录用户的权限,然后每当新打开一个页面的时候进行检验。(注销登陆的时候需要删除COOKIES)