前边一个有把在 global 中通过用户名到数据库去验证,这个中是直接在用户登陆时把用户角色存在 cookie 中,在 global 中去进行验证,可能比前一个要效率高吧.... web.config <authentication mode="Forms"> <forms name=".test" loginUrl="bb.aspx" timeout="30" path="/"></forms> </authentication> <authorization> <deny users="?"></deny> </authorization> User.xml <?xml version="1.0" encoding="utf-8" ?> <roles> <user name="Bob" roles="Sales" /> <user name="Jane" roles="Supervisor,Sales" /></roles> bb.aspx private void Button1_Click(object sender, System.EventArgs e) } Global.asax protected void Application_AuthenticateRequest(Object sender, EventArgs e) } default.aspx private void Page_Load(object sender, System.EventArgs e) } 相关文章: