Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

ASP Net - IHttpModule Questions

 
Thread Tools Search this Thread
Old 06-03-2008, 05:42 PM   #1
Default IHttpModule Questions


Greetings,

So, I now have a custom IHttpModule class that I use to establish the Theme
for each page, based on the user's settings. Seems to work just fine. Thanks
to everyone who made helpful suggestions.

The code I copied looked something like the listing below. In the Init
method, it sets a handler for PreRequestHandlerExecute. And then in the
PreRequestHandlerExecute method, it sets a handler for the page's PreInit.
The result is that I have a global handler for every pages' PreInit.

But now I'm wondering if this many layers is required. Is there any reason
to not simply set the page's theme in the PreRequestHandlerExecute method,
and eliminate the PreInit handler? It even seems like all my session and
membership data is available during PreRequestHandlerExecute (although some
of my database data is cached in the Session object). How would I determine
if I need the PreInit handler?

Thanks.

public class ThemeManager : IHttpModule
{
public ThemeManager()
{
}

public void Init(HttpApplication app)
{
app.PreRequestHandlerExecute += new
EventHandler(Context_PreRequestHandlerExecute);
}

void Context_PreRequestHandlerExecute(object sender, EventArgs e)
{
Page page = HttpContext.Current.CurrentHandler as Page;
if (page != null)
page.PreInit += new EventHandler(Page_PreInit);
}

void Page_PreInit(object sender, EventArgs e)
{
Page page = (Page)sender;
// Set page theme here!
}

public void Dispose()
{
}
}

Jonathan



Jonathan Wood
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
70-536 questions and time limit for exam? type of questions? gravz84 MCTS 2 11-22-2007 07:57 PM
70-536 questions and time limit for exam? type of questions? gravz84 MCTS 0 11-13-2007 05:44 PM
70-536 Details Gary Gallagher MCTS 10 06-30-2007 01:08 PM
Re: A+ Test Questions jsaulinskas@sbcglobal.net A+ Certification 0 01-20-2005 03:19 AM
A+ Exam Anthony Coletta A+ Certification 5 05-07-2004 10:07 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46