我在Application_OnPostAuthenticateRequest
中使用global.asax
事件来获取
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;
}
}
我的问题如下:
答案 0 :(得分:4)
HttpCurrent.Current.Cache
来存储用户特定信息,因为缓存对所有用户都是通用的,您将会遇到冲突。请改用HttpContext.Current.Session
,因为这将特定于用户。