fail to get Application object???

Discussion in 'ASP .Net' started by =?Utf-8?B?aGFpd2Vu?=, Feb 16, 2005.

  1. Hello, sir/madam:

    If I add a webForm, there is not problem to access the Applicaton and
    Session object;
    but if I add a class and then inherit Page object, I can access Session
    object but NOT Application object, I always get NULL reference exception for
    Application even the class has the same using statements as the webForm
    class.!!!

    Could anyone tell me why and help me out?

    I do appreciate your help.

    haiwen
     
    =?Utf-8?B?aGFpd2Vu?=, Feb 16, 2005
    #1
    1. Advertising

  2. A Page is an HttpHandler, which means that these types of objects are
    populated when the Page receives a Request. Inheriting the Page class in a
    Business class doesn't make the Business class the HttpHandler for the
    Request.

    If you want to access Application and Session from a business class, refer
    to the current HttpContext. Example:

    System.Web.HttpApplicationState app = HttpContext.Current.Application;

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    Neither a follower nor a lender be.


    "haiwen" <> wrote in message
    news:...
    > Hello, sir/madam:
    >
    > If I add a webForm, there is not problem to access the Applicaton and
    > Session object;
    > but if I add a class and then inherit Page object, I can access Session
    > object but NOT Application object, I always get NULL reference exception
    > for
    > Application even the class has the same using statements as the webForm
    > class.!!!
    >
    > Could anyone tell me why and help me out?
    >
    > I do appreciate your help.
    >
    > haiwen
     
    Kevin Spencer, Feb 16, 2005
    #2
    1. Advertising

  3. Thank you, kevin.

    haiwen

    "Kevin Spencer" wrote:

    > A Page is an HttpHandler, which means that these types of objects are
    > populated when the Page receives a Request. Inheriting the Page class in a
    > Business class doesn't make the Business class the HttpHandler for the
    > Request.
    >
    > If you want to access Application and Session from a business class, refer
    > to the current HttpContext. Example:
    >
    > System.Web.HttpApplicationState app = HttpContext.Current.Application;
    >
    > --
    > HTH,
    >
    > Kevin Spencer
    > Microsoft MVP
    > ..Net Developer
    > Neither a follower nor a lender be.
    >
    >
    > "haiwen" <> wrote in message
    > news:...
    > > Hello, sir/madam:
    > >
    > > If I add a webForm, there is not problem to access the Applicaton and
    > > Session object;
    > > but if I add a class and then inherit Page object, I can access Session
    > > object but NOT Application object, I always get NULL reference exception
    > > for
    > > Application even the class has the same using statements as the webForm
    > > class.!!!
    > >
    > > Could anyone tell me why and help me out?
    > >
    > > I do appreciate your help.
    > >
    > > haiwen

    >
    >
    >
     
    =?Utf-8?B?aGFpd2Vu?=, Feb 17, 2005
    #3
    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. Wenjie

    if (f() != FAIL) or if (FAIL != f())?

    Wenjie, Jul 28, 2003, in forum: C Programming
    Replies:
    3
    Views:
    451
    E. Robert Tisdale
    Jul 31, 2003
  2. wardy
    Replies:
    4
    Views:
    1,070
    wardy
    Mar 14, 2008
  3. Greg Stangler
    Replies:
    5
    Views:
    219
    Greg Stangler
    Feb 9, 2005
  4. csw

    Fail to create IXSSO.Query object

    csw, Jun 8, 2010, in forum: ASP General
    Replies:
    9
    Views:
    1,798
  5. Lasse Svensson
    Replies:
    4
    Views:
    180
    Lasse Svensson
    Feb 15, 2008
Loading...

Share This Page