Current.Handler is nothing within business object

J

John Zullo

When I look at the HTTPContext.Current at a breakpoint in a Business Object
instanntiated by a Page class, the Handler is set to nothing. It only has a
value from within the page class itself. I was hoping to get a reference to
the page object via CType(httpcontext.current.handler,page) Anything special
I need to do to be able to access this?

TIA,

John Zullo
 
J

John Zullo

Did some debugging, and it looks like current.handler is only available to
controls after the page load has executed. I have tried this with the object
as a plain class and as one that inherits system.web.ui.control with the
same results.
 
J

John Zullo

The current.handler is Nothing in the constructor of the business object.
Later in the business object it has a value.
 
J

John Zullo

The business class is instantiated at the top of the page class:

Public Class GtRfcChanges1

Inherits System.Web.UI.Page



Protected GtDB As New GtDB

Protected GtDict As New GtDict

Protected GtLayout As New GtLayout(Me)

I would like to replace the declaration of GtLayout with

Protected GtLayout as GtLayout = GtLayout.Instance

so I can use a singleton pattern for this object, which I don't think I can
do if I have to pass the page object in the constructor.
 
B

Brock Allen

The business class is instantiated at the top of the page class:
Public Class GtRfcChanges1
Inherits System.Web.UI.Page
Protected GtLayout As New GtLayout(Me)

Ok, I bet your problem is that you're accessing Page.Request and not HttpContext.Current.Request
in the constructor. The Page does not yet have those references in its constructor.
Change your business logic to HttpContext.Current.Request instead and it
should work.

-Brock
DevelopMentor
http://staff.develop.com/ballen
 
S

Scott Allen

Hi John:

For web forms - the Handler property will be the Page object itself.
You won't be able to get a reference from inside the ctor since the
object hasn't yet been constructed! :)
 
S

Scott Allen

Correct - I couldn't quite determine what you needed to do at that
point or I'd offer a suggestion for a different approach.
 
J

John Zullo

Thanks all for your help.

Scott Allen said:
Correct - I couldn't quite determine what you needed to do at that
point or I'd offer a suggestion for a different approach.
 

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

Top