473,387 Members | 1,348 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,387 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 1918
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.