用FormsAuthentication与数据库结合,怎么做? 用FormsAuthentication与数据库结合,怎么做? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你可以自己定义一个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();} http://www.codeproject.com/aspnet/formsroleauth.aspthis sample give you full code 最简单的方法,在你 login 表单的提交按钮的响应事件里加:string user = Request["user"];string pass = Request["pass"];if (checkPassword(user, pass)){ FormsAuthentication.RedirectFromLoginPage(user, false);}在 checkPassword() 里你可以去读数据库验证密码。 js如何取checkboxlist的值 一个asp.net web系统用了2年,发生了怪异问题,请求帮助! 关于Repeater简单问题 Repeater绑定问题 用Repeater控件在一行中如何显示多条标题 GridView模板列如何给button绑定数据 然后按用这个button传送ID?大虾指点指点? ie直接打开EXECL不要出"打开","保存"问题解决结贴 从数据库读取用户名及密码并登录网站 用户控件问题 在asp.net中,如何用DataGrid或DataList或Repeater显示一定长度的数据? asp.net如何删除文件? 字符串分割问题C#
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();
}
string pass = Request["pass"];
if (checkPassword(user, pass))
{
FormsAuthentication.RedirectFromLoginPage(user, false);
}在 checkPassword() 里你可以去读数据库验证密码。