Current.Handler is nothing within business object

  • Thread starter Thread starter John Zullo
  • Start date Start date
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
 
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.
 
The current.handler is Nothing in the constructor of the business object.
Later in the business object it has a value.
 
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.
 
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
 
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! :)
 
Correct - I couldn't quite determine what you needed to do at that
point or I'd offer a suggestion for a different approach.
 
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

Back
Top