Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > fail to get Application object???

Reply
Thread Tools

fail to get Application object???

 
 
=?Utf-8?B?aGFpd2Vu?=
Guest
Posts: n/a
 
      02-16-2005
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
 
Reply With Quote
 
 
 
 
Kevin Spencer
Guest
Posts: n/a
 
      02-16-2005
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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



 
Reply With Quote
 
 
 
 
=?Utf-8?B?aGFpd2Vu?=
Guest
Posts: n/a
 
      02-17-2005
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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
16?, bit application fail to work ?.. tony sayer Computer Information 1 04-24-2007 09:34 PM
Hi I have one web application and i want to get the number of users who are currently accessing the application. Also I want to get the user details of each user, which is stored in a database. How can I do this? Pls help. Getting No: and anu Java 11 05-12-2005 03:25 PM
Application installs fail in W2K Paul Eden Computer Support 25 08-11-2003 05:59 AM
[Fwd: Application installs fail in W2K] Paul Eden Computer Support 0 08-09-2003 01:11 PM
if (f() != FAIL) or if (FAIL != f())? Wenjie C Programming 3 07-31-2003 09:54 PM



Advertisments