Re: fail to get Application object???
From: Kevin Spencer (kevin_at_DIESPAMMERSDIEtakempis.com)
Date: 02/16/05
- Next message: Ollie Riches: "Re: DataGrid having ListBox and Hyperlink"
- Previous message: Tom wilson: "Re: Dealing with the Back button"
- In reply to: haiwen: "fail to get Application object???"
- Next in thread: haiwen: "Re: fail to get Application object???"
- Reply: haiwen: "Re: fail to get Application object???"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 16 Feb 2005 11:26:11 -0500
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" <haiwen@discussions.microsoft.com> wrote in message news:B7DB5B8D-BC01-449B-8AC8-3C0E5608219B@microsoft.com... > 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
- Next message: Ollie Riches: "Re: DataGrid having ListBox and Hyperlink"
- Previous message: Tom wilson: "Re: Dealing with the Back button"
- In reply to: haiwen: "fail to get Application object???"
- Next in thread: haiwen: "Re: fail to get Application object???"
- Reply: haiwen: "Re: fail to get Application object???"
- Messages sorted by: [ date ] [ thread ]