用FormsAuthentication与数据库结合,怎么做?

解决方案 »

  1.   

    你可以自己定义一个Http模块或者在Global.asax中处理
    public void Application_AuthenticateRequest(object sender, EventArgs e)
    {
        HttpApplication app = (HttpApplication)sender;
        //获得用户请求页面
        string path = app.Request.Path;
        //获得用户名称
        string user = app.User.Identity.Name;
        //连接数据库获得用户权限
        string role = GetUserRole();
    }
      

  2.   

    http://www.codeproject.com/aspnet/formsroleauth.aspthis sample give you full code
      

  3.   

    最简单的方法,在你 login 表单的提交按钮的响应事件里加:string user = Request["user"];
    string pass = Request["pass"];
    if (checkPassword(user, pass))
    {
      FormsAuthentication.RedirectFromLoginPage(user, false);
    }在 checkPassword() 里你可以去读数据库验证密码。