Application_BeginRequest questions

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 "".
 
C

Cowboy \(Gregory A. Beamer\) [MVP]

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!
************************************************
 
S

Scott Allen

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
 
J

JezB

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top