473,748 Members | 10,048 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Cur rent.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.Cur rent.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 1950
Hi Steve:

I'm a little confused -

You have a class derived from System.Web.UI.P age 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.Cur rent.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.c omcast.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.Cur rent.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.Cur rent.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.Cu rrent.Handler) which is then cast into a
MasterPage, in order to get the PageTitle.

The problem is that with an HttpHandler, the HttpContext.Cur rent.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.Ite m, or creating an HttpHandler factory instead of using a
true HttpHandler).

Thanks for looking at this for me.

Steve

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

I'm a little confused -

You have a class derived from System.Web.UI.P age 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.Cur rent.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.c omcast.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.Cur rent.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.Cur rent.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.c omcast.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.Cu rrent.Handler) which is then cast into a
MasterPage, in order to get the PageTitle.

The problem is that with an HttpHandler, the HttpContext.Cur rent.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.It em, or creating an HttpHandler factory instead of using a
true HttpHandler).

Thanks for looking at this for me.

Steve

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

I'm a little confused -

You have a class derived from System.Web.UI.P age 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.Cur rent.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.c omcast.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.Cur rent.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
HttpHandle r 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.Cur rent.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
2768
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: .... assigns an internal rewrite path. RewritePath allows for the URL that is requested to differ from the internal path to the resource. What does this mean? When would it be useful to have the paths differ ?
4
3845
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 requesting the webapplication using urls like http://localhost/<ApplicationName>/... everything works fine. A new session is created, and reused on every following requests (same
3
4887
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 ConfigurationSettings.AppSettings call. My guess is, there's a security setting that I'm missing on my Server but what?? I've spend hours trying to debug this; help on this would be greatly appreciated... Here's the error I get:
7
2745
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 QueryString pairs are placed in HttpContext.Current.Items and retrieved with a wrapper for Request.Params that includes checks there. This works in general instances, but one problem has come up that has me stuck: since the stuff is in the context and...
2
2820
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. This fix is included automatically in SP1 for Windows Server 2003 also, and I have been unable to remove it until we can find out how to fix this problem. The error message is below,
0
3225
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. http://i103.photobucket.com/albums/m135/handlex/RandomPhotos/Buttsex_to-Korn.jpg This is showing the properties of certain IPs located in the zone that is having the issue. Stemming off my "Network Issue" thread, I've decided to close it because that was the issue was found and now to find the...
2
3117
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() Thread.Sleep(1000)
1
1817
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 if the file is located in the root directory, if I try to transfer context to a file in a subdirectory the Server.Transfer method returns an error, any thoughts on this? Thank you
2
3041
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 page that will generate the content dynamically. The problem is that after the call to Server.Transfer or Server.Execute the page i'm transfering to throws an exception when it tries to access the Session object. The error says that I must set...
0
8989
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9537
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9367
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9319
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4599
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4869
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3309
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2213
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.