问1.据我所知FormsAuthenticationModule,订阅了AuthenticateRequest事件,因此只有在触发此事件后才会FormsAuthenticationModule调用.但是下面的引言让我有些困惑:
该
AuthenticateRequest事件表示配置的身份验证机制已对当前请求进行身份验证.
AuthenticateRequest引发事件时,请求(也称为用户)已经过身份验证? 订阅
AuthenticateRequest事件可确保在处理附加模块或事件处理程序之前对请求进行身份验证.
AuthenticatedRequest,那么我们的事件处理程序将在之前被调用FormsAuthenticationModule?这样Application_AuthenticateRequest()叫之前会FormsAuthenticationModule被称为?问2.我正在学习的书建议Application_AuthenticateRequest()我们能够验证用户是否是特定角色的成员,如果没有,我们可以自动添加用户:
protected void Application_AuthenticateRequest(Object sender, EventArgs e)
{
if (User.Identity.IsAuthenticated && Roles.Enabled)
{
//here we can subscribe user to a role via Roles.AddUserToRole()
}
}
Run Code Online (Sandbox Code Playgroud)
从上面的代码判断,Application_AuthenticateRequest()调用后FormsAuthenticationModule调用,但在其他地方相同的书暗示Application_AuthenticateRequest()在之前调用FormsAuthenticationModule:
Application_AuthenticateRequest在执行身份验证之前调用.这是创建自己的身份验证逻辑的起点.
我错过了什么?
感谢名单
c# asp.net authentication forms-authentication httpapplication