我开发了一个 HttpModule,用于PreInit
在登录用户的个人资料中为页面分配主题。但似乎配置文件在我访问它时没有初始化。是否有一个特定的事件,之后我应该访问类似于事件后访问页面 cotnrolls 的用户的个人资料Init
。顺便说一句,我在 ASP.NET 2.0 和自定义配置文件提供程序实现上运行。
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
在我的应用程序的每个页面的舞台上执行。