Application_BeginRequest questions

Discussion in 'ASP .Net' started by JezB, Jul 6, 2004.

  1. JezB

    JezB Guest

    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 "".
    JezB, Jul 6, 2004
    #1
    1. Advertising

  2. 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!
    ************************************************
    "JezB" <> wrote in message
    news:...
    > 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

    "".
    >
    >
    >
    >
    >
    >
    >
    >
    Cowboy \(Gregory A. Beamer\) [MVP], Jul 6, 2004
    #2
    1. Advertising

  3. JezB

    Scott Allen Guest

    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

    --
    Scott
    http://www.OdeToCode.com

    On Tue, 6 Jul 2004 15:21:10 +0100, "JezB"
    <> wrote:

    >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 "".
    >
    >
    >
    >
    >
    >
    >
    Scott Allen, Jul 6, 2004
    #3
  4. JezB

    JezB Guest

    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.

    "Cowboy (Gregory A. Beamer) [MVP]" <> wrote
    in message news:...
    > 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!
    > ************************************************
    > "JezB" <> wrote in message
    > news:...
    > > 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

    > "".
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >

    >
    >
    JezB, Jul 6, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Cynic07
    Replies:
    1
    Views:
    476
    Cynic07
    Jul 31, 2003
  2. Amil
    Replies:
    1
    Views:
    480
    William F. Robertson, Jr.
    Feb 19, 2004
  3. =?Utf-8?B?UGF1bCBEYWx5IChNQ1Ap?=

    Session Start / Application_BeginRequest Issues

    =?Utf-8?B?UGF1bCBEYWx5IChNQ1Ap?=, Jul 4, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    6,891
    Craig Deelsnyder
    Jul 4, 2004
  4. Stu
    Replies:
    2
    Views:
    9,341
  5. Leon
    Replies:
    1
    Views:
    483
Loading...

Share This Page