0
我開發了一個HttpModule,用於在登錄用戶的配置文件PreInit
事件期間爲頁面分配主題。但似乎該配置文件在我訪問它時未初始化。是否有一個特定的事件後,我應該訪問配置文件,類似於Init
事件後的訪問頁面cotnrols。順便說一句,我運行在ASP.NET 2.0和自定義配置文件提供程序的實現。何時初始化UserProfile
public void CurrentPageOnPreInit(object sender, EventArgs e)
{
//Get the page currently requested
Page currentPage = (Page)sender;
//Get the user profile
ProfileCommon userProfile = HttpContext.Current.Profile as ProfileCommon;
//check if user profile has theme set
if (userProfile != null && !string.IsNullOrEmpty(userProfile.Theme))
{
//retrieve from profile
currentPage.Theme = userProfile.Theme;
其中上述方法在我的應用程序上的每個頁面的PreInit
階段執行。
因爲我有自定義實現我必須做這個顯式?像'ProfileCommon.Create(UserName)'我希望不是這樣,因爲這是由asp.net框架在頁面解析期間自動執行的,我正在尋找確切的事件,這是進行 – Deeptechtons 2012-03-19 06:24:41