php global.asax 病毒,身份验证-Global.asax事件:Application_OnPostAuthenticateRequest

我在global.asax中使用Application_OnPostAuthenticateRequest事件获取

a)身份验证用户的角色和权限我也创建了自定义主体类,以获取用户详细信息以及角色和权限.

b)获得一些对该用户相同的信息.

void Application_OnPostAuthenticateRequest(object sender, EventArgs e)

{

// Get a reference to the current User

IPrincipal objIPrincipal = HttpContext.Current.User;

// If we are dealing with an authenticated forms authentication request

if ((objIPrincipal.Identity.IsAuthenticated) && (objIPrincipal.Identity.AuthenticationType == "Forms"))

{

CustomPrincipal objCustomPrincipal = new CustomPrincipal();

objCustomPrincipal = objCustomPrincipal.GetCustomPrincipalObject(objIPrincipal.Identity.Name);

HttpContext.Current.User = objCustomPrincipal;

CustomIdentity ci = (CustomIdentity)objCustomPrincipal.Identity;

HttpContext.Current.Cache["CountryID"] = FatchMasterInfo.GetCountryID(ci.CultureId);

HttpContext.Current.Cache["WeatherLocationID"] = FatchMasterInfo.GetWeatherLocationId(ci.UserId);

Thread.CurrentPrincipal = objCustomPrincipal;

}

}

我的问题如下:

>对于每个请求,每次都会触发此事件.因此对于每个请求代码执行?

>我的方法正确与否?

>在此事件中添加HttpContext.Current.Cache是??否正确,否则我们应该将其移至Session_Start

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值