3
我正在使用global.asax
Application_OnPostAuthenticateRequest
事件得到的Global.asax事件:Application_OnPostAuthenticateRequest
一)角色和身份驗證的用戶的權限,還我已經做了我的自定義主體類來獲取用戶詳細信息和角色和權限。
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
Thnaks, 再次提高几倍? 如果此事件針對每個請求觸發,那麼對於每個請求,我將執行與角色和授權的數據庫連接。這是否好,我們不能在會話啓動事件中做同樣的事情。 – 2009-07-18 11:22:25