473,396 Members | 1,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Issue with HttpContext and HttpHandlers with Server.Transfer

Hello All,

I have an ASPX page whose class inherits from a company global base page.

The company base page has a property call PageTitle (string) that is
assigned by all the pages.
The base class also includes a class that is used for logging. This logging
class uses HttpContext.Current.Handler to get the instance of the page. In
this way, it can get the PageTitle property.

This works just fine with normal .ASPX pages, however, I also have an
HttpHandler that handles special URL's. This handler determines the page
that should handle the request, and then does a server.transfer to the
correct page.

The handler works, however, upon instantiation of the logging class of the
base page, it gets an error because the HttpContent.Current.Handler says
that it's the HttpHandler, and not the basepage.

Is there anyway I can get the instance of the Page's class, instead of the
Handler's class after using a HttpHandler and a Server.Transfer?

Thanks

Steve
Nov 19 '05 #1
3 1919
Hi Steve:

I'm a little confused -

You have a class derived from System.Web.UI.Page that serves as a base
class for all your pages. The base class includes the PageTitle
property and some logging code. Why does the class use
HttpContext.Current.Handler to get a reference to itself? Is the
method static / shared?

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Mon, 20 Jun 2005 21:53:04 -0400, "Steve Lutz"
<sl***@nospam.comcast.net> wrote:
Hello All,

I have an ASPX page whose class inherits from a company global base page.

The company base page has a property call PageTitle (string) that is
assigned by all the pages.
The base class also includes a class that is used for logging. This logging
class uses HttpContext.Current.Handler to get the instance of the page. In
this way, it can get the PageTitle property.

This works just fine with normal .ASPX pages, however, I also have an
HttpHandler that handles special URL's. This handler determines the page
that should handle the request, and then does a server.transfer to the
correct page.

The handler works, however, upon instantiation of the logging class of the
base page, it gets an error because the HttpContent.Current.Handler says
that it's the HttpHandler, and not the basepage.

Is there anyway I can get the instance of the Page's class, instead of the
Handler's class after using a HttpHandler and a Server.Transfer?

Thanks

Steve


Nov 19 '05 #2
Hi Scott,

You were on the right track, but you fell off a little - sorry about the
poor explaination, here's a better one:

The Master baseclass contains a property called PageTitle. (We'll call this
class MasterPage)

There is another class called PageContext which is used to generate
Analyitic information. An instance of the PageContext class is created in
MasterPage's
contstructor. PageContext requires PageTitle from the masterPage to do it's
work. So to get this:

PageContext uses the current HttpContext to get the instance of the page
that it's on (HttpContext.Current.Handler) which is then cast into a
MasterPage, in order to get the PageTitle.

The problem is that with an HttpHandler, the HttpContext.Current.Handler is
not the MasterPage, even after a Server.Transfer to a page that does inherit
from MasterPage.

So the question is, is it possible to get the instance of the actual page
that is currently executing? I know it exists, because an instance
PageContext exists and that is created by the MasterPage.

I do have some-workaround changes (like sticking PageContext into an
HttpContext.Item, or creating an HttpHandler factory instead of using a
true HttpHandler).

Thanks for looking at this for me.

Steve

"Scott Allen" <sc***@nospam.odetocode.com> wrote in message
news:1v********************************@4ax.com...
Hi Steve:

I'm a little confused -

You have a class derived from System.Web.UI.Page that serves as a base
class for all your pages. The base class includes the PageTitle
property and some logging code. Why does the class use
HttpContext.Current.Handler to get a reference to itself? Is the
method static / shared?

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Mon, 20 Jun 2005 21:53:04 -0400, "Steve Lutz"
<sl***@nospam.comcast.net> wrote:
Hello All,

I have an ASPX page whose class inherits from a company global base page.

The company base page has a property call PageTitle (string) that is
assigned by all the pages.
The base class also includes a class that is used for logging. This
logging
class uses HttpContext.Current.Handler to get the instance of the page. In
this way, it can get the PageTitle property.

This works just fine with normal .ASPX pages, however, I also have an
HttpHandler that handles special URL's. This handler determines the page
that should handle the request, and then does a server.transfer to the
correct page.

The handler works, however, upon instantiation of the logging class of the
base page, it gets an error because the HttpContent.Current.Handler says
that it's the HttpHandler, and not the basepage.

Is there anyway I can get the instance of the Page's class, instead of the
Handler's class after using a HttpHandler and a Server.Transfer?

Thanks

Steve

Nov 19 '05 #3
Oh! Makes sense now :)

I'm trying this out and do not see a way, offhand. In fact my Handler
property is null after the transfer, which is really odd. Are you
doing the Server.Transfer during the BeginRequest event handler for
your module? That's where mine is.

--
Scott
http://www.OdeToCode.com/blogs/scott/
On Tue, 21 Jun 2005 21:03:15 -0400, "Steve Lutz"
<sl***@nospam.comcast.net> wrote:
Hi Scott,

You were on the right track, but you fell off a little - sorry about the
poor explaination, here's a better one:

The Master baseclass contains a property called PageTitle. (We'll call this
class MasterPage)

There is another class called PageContext which is used to generate
Analyitic information. An instance of the PageContext class is created in
MasterPage's
contstructor. PageContext requires PageTitle from the masterPage to do it's
work. So to get this:

PageContext uses the current HttpContext to get the instance of the page
that it's on (HttpContext.Current.Handler) which is then cast into a
MasterPage, in order to get the PageTitle.

The problem is that with an HttpHandler, the HttpContext.Current.Handler is
not the MasterPage, even after a Server.Transfer to a page that does inherit
from MasterPage.

So the question is, is it possible to get the instance of the actual page
that is currently executing? I know it exists, because an instance
PageContext exists and that is created by the MasterPage.

I do have some-workaround changes (like sticking PageContext into an
HttpContext.Item, or creating an HttpHandler factory instead of using a
true HttpHandler).

Thanks for looking at this for me.

Steve

"Scott Allen" <sc***@nospam.odetocode.com> wrote in message
news:1v********************************@4ax.com.. .
Hi Steve:

I'm a little confused -

You have a class derived from System.Web.UI.Page that serves as a base
class for all your pages. The base class includes the PageTitle
property and some logging code. Why does the class use
HttpContext.Current.Handler to get a reference to itself? Is the
method static / shared?

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Mon, 20 Jun 2005 21:53:04 -0400, "Steve Lutz"
<sl***@nospam.comcast.net> wrote:
Hello All,

I have an ASPX page whose class inherits from a company global base page.

The company base page has a property call PageTitle (string) that is
assigned by all the pages.
The base class also includes a class that is used for logging. This
logging
class uses HttpContext.Current.Handler to get the instance of the page. In
this way, it can get the PageTitle property.

This works just fine with normal .ASPX pages, however, I also have an
HttpHandler that handles special URL's. This handler determines the page
that should handle the request, and then does a server.transfer to the
correct page.

The handler works, however, upon instantiation of the logging class of the
base page, it gets an error because the HttpContent.Current.Handler says
that it's the HttpHandler, and not the basepage.

Is there anyway I can get the instance of the Page's class, instead of the
Handler's class after using a HttpHandler and a Server.Transfer?

Thanks

Steve


Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Guadala Harry | last post by:
I'd really appreciate it if someone would give me a"plain English" explanation of HttpContext.RewritePath(). I read the MSDN documentation, but still don't understand it. According to MSDN:...
4
by: Nicolas Beunier | last post by:
Hi! I am currently working on a Web Application using some HttpHandlers. As i need to read/update objects stored in session, each Handler implements the IRequestSessionState interface. When...
3
by: Celebrate | last post by:
My application works fine when I run it locally but when I transfer it to our NEW Windows 2003 Web Edition server, I get a strange error. I've isolated the problem to when I issue a...
7
by: Keith Patrick | last post by:
After completely giving up on finding some way in my ASP.Net app to take a query string URL and redirect to it as a POST instead, I went with a system like so: Upon "redirection," all the...
2
by: Leon | last post by:
Hello all, I have come across an issue with the fix KB886903 - http://www.microsoft.com/technet/security/Bulletin/MS05-004.mspx which is to do with the ASP.Net path validation vulnerability....
0
by: HandleX609 | last post by:
http://i103.photobucket.com/albums/m135/handlex/RandomPhotos/Buttsex_to-Korn.jpg This is the snapshot stating the event for a certain zone. ...
2
by: =?Utf-8?B?YWxiZXJ0b3Nvcmlh?= | last post by:
Hi, I'm using Threads, and when I try to do Server.Transfer, I recieved an error. (child object does not exist...) My Code: Dim t As New Thread(AddressOf Hilo) Private Sub Hilo()...
1
by: mmorrison93 | last post by:
Thanks in advance for any help on this problem, but i have an HttpHandler that looks at the requested url and and tranfers context to a particular file. The problem is the transfer will only work...
2
by: Fernando Rodriguez | last post by:
I created an HttpHandler for rewritting URLs. It simply checks if the requested page is on a list of "special" pages (that do not exist) and if it is on the list then it will transfer to an ASPX...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.