Application_BeginRequest questions

  • Thread starter Thread starter JezB
  • Start date Start date
J

JezB

1) How can I access my object-oreinted classes from the global.asax
Application_BeginRequest event ?
I cannot instantiate them from session since it complains :
Session state is not available in this context

2) How can I get the name of the Page being requested from within
Application_BeginRequest ?
((System.Web.UI.Page)HttpContext.Current.Handler).ToString() returns "".
 
Request.Url will give you the full path. You can tear that down to get a
specific page.

If you posted the actual problem, sans the proposed solution (using App_BR),
you might get some better architectural guidelines for this problem.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
 
Properties on Request.Url should be able to give you the path and page
being requested.

If your object is kept in the Session object, you just won't be able
to get to it from BeginRequest. Perhaps you might want to check out
the Items collection, I have some sample code here:

http://www.odetocode.com/Articles/111.aspx
 
I have found that I can do what I want in global.asax's
Application_PreRequestHandlerExecute event, since this has Session
available. I'm puzzled why Application_BeginRequest doesn't though.
 
Back
Top