fail to get Application object???

G

Guest

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
 
K

Kevin Spencer

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.
 
G

Guest

Thank you, kevin.

haiwen

Kevin Spencer said:
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.
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top