473,466 Members | 1,381 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Server.Transfer and IHttpModule problem

I've developed a small ASPX template framework (based on Chun Li's
article on CodeProject:
http://www.codeproject.com/aspnet/he...asp#xx849313xx) which
uses a IHttpModule to apply usercontrols (e.g. header and footer) on
pages.
The module determines if templates should be added to the page using
Page.Request.Path. It matches the current adress to settings found in a
configuration-file...

It works like a charm except for one little problem with
HttpServerUtility.Transfer.
Server.Transfer doesn't change the path-related properties needed.

I realize that the Path-property might not be the correct property to
use in this particular case.
The documentation states that the HttpRequest.CurrentExecutionFilePath
property should change when Server.Transfer is called.
I've verified that it does on the target/child page by outputting the
variable.

The problem lies in the fact that the property hasn't changed in the
IHttpModule.
I'm using the HttpApplication.Context which is of type
System.Web.UI.Page to attach an eventhandler to the Page.Init-event.

Is this a bug or am I missing something here!?

I want a non-intrusive way to add templates to any page. This means
that the page can't know anything about templates, such as utilizing
RewritePath which might avoid the problem.

Regards,
Richard

Jan 31 '06 #1
5 2163
Richard,

Server.Transfer executes the page being requested without going back to the
client. It's a more direct, faster way to send a client a page. Here's a
comparison:

If a client requests page1 of your website and then posts back and you
execute a Response.Redirect to page2 the client browser is sent new code
that tells it to go to page2. Therefore in this scenario your handler gets
the correct page because the client has requested it.

If a client requests page1 of your web then posts back and you execute a
Server.Transfer to page2 the client browser is not contacted at all. Instead
the web server sends page2 to the client as if page2 is page1. The client
doesn't even know it's on a different page.

The context object is a common way to pass values from one page to another
when using Server.Transfer. Just before the transfer a value may be added to
the context object: Context.Item.Add("[Key]", [Value as Object]). Then on
the new page the same context object may be accessed via its key:
Context.Item("[Key]"). Perhaps you could set a context object when utilizing
Server.Transfer in order to set your template. I don't know for certain if a
context item will be accesible to your module... But it's worth a try.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Richard" <ri*****@metavision.se> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
I've developed a small ASPX template framework (based on Chun Li's
article on CodeProject:
http://www.codeproject.com/aspnet/he...asp#xx849313xx) which
uses a IHttpModule to apply usercontrols (e.g. header and footer) on
pages.
The module determines if templates should be added to the page using
Page.Request.Path. It matches the current adress to settings found in a
configuration-file...

It works like a charm except for one little problem with
HttpServerUtility.Transfer.
Server.Transfer doesn't change the path-related properties needed.

I realize that the Path-property might not be the correct property to
use in this particular case.
The documentation states that the HttpRequest.CurrentExecutionFilePath
property should change when Server.Transfer is called.
I've verified that it does on the target/child page by outputting the
variable.

The problem lies in the fact that the property hasn't changed in the
IHttpModule.
I'm using the HttpApplication.Context which is of type
System.Web.UI.Page to attach an eventhandler to the Page.Init-event.

Is this a bug or am I missing something here!?

I want a non-intrusive way to add templates to any page. This means
that the page can't know anything about templates, such as utilizing
RewritePath which might avoid the problem.

Regards,
Richard

Jan 31 '06 #2
Thank you for your reply!

I'm aware of the differences between Response.Redirect and
Server.Transfer and how they work, unfortunately some of the pages I'm
applying this solution to needs to be able to work with
Server.Transfer.

Using the Context-object works fine but that would make the pages aware
of the template-framework which is what I want to avoid.

The question is why the CurrentExecutionFilePath remains the same
during the call to the IHttpModule but has changed when the child page
receives the call.
Even though I've attached eventhandlers to the exact same event
(Page.Init) and most likely the same Page-object the property differs.

If you have access to the source of the Server.Transfer-method you will
see that the method is responsible for changing the property on the
HttpRequest-object of the current page.

/ Richard

Feb 1 '06 #3
Richard,

My belief is that when Server.Transfer is called it bypasses the IHttpModule
completely and just loads up the child page.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Richard" <ri*****@metavision.se> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Thank you for your reply!

I'm aware of the differences between Response.Redirect and
Server.Transfer and how they work, unfortunately some of the pages I'm
applying this solution to needs to be able to work with
Server.Transfer.

Using the Context-object works fine but that would make the pages aware
of the template-framework which is what I want to avoid.

The question is why the CurrentExecutionFilePath remains the same
during the call to the IHttpModule but has changed when the child page
receives the call.
Even though I've attached eventhandlers to the exact same event
(Page.Init) and most likely the same Page-object the property differs.

If you have access to the source of the Server.Transfer-method you will
see that the method is responsible for changing the property on the
HttpRequest-object of the current page.

/ Richard

Feb 1 '06 #4
That was my initial belief too but the IHttpModule is called every
time.

I simply accessed the Page.Response (from inside the IHttpModule) to
output a new GUID every time the IHttpModule was called to see if it
did.

/ Richard

Feb 2 '06 #5
Hmmmm,

Well, then, that's very strange. I'm afraid I don't have an answer for you.
I'll look around and see if I find anything. But I wouldn't have expected
the behaviour you're seeing based on this information.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Richard" <ri*****@metavision.se> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
That was my initial belief too but the IHttpModule is called every
time.

I simply accessed the Page.Response (from inside the IHttpModule) to
output a new GUID every time the IHttpModule was called to see if it
did.

/ Richard

Feb 2 '06 #6

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

Similar topics

5
by: Nedu N | last post by:
Hi All, I am facing a typical problem in my .NET application with the pop-up script messages. The thing is that its working fine when i run on my development machine but not running in expected...
2
by: Kenneth Myhra | last post by:
Hi, We have been trying to develop an IHTTPModule (that was supposed to replace or take over the ISAPI Filters, as far as we know). We have developed one in C# and it seems to be working. The...
2
by: Kenneth Myhra | last post by:
Hi all, We are trying to make an ISAPI Filter, in .NET by implementing the IHttpModule interface, that will authorize the request for certain binary file types (GET), this is working fine. But we...
9
by: Mark | last post by:
Hello I'm trying to use a Server.Transfer in a try-catch (I cannot put it outside the Try-Catch as it is nested deep within a component that is called in a try-catch loop) The problem is that the...
5
by: Guadala Harry | last post by:
I've been reading up on Server.Transfer as well as doing some testing, and it appears to always raise the ThreadAbortException error. On one hand I've read a bunch of promotional-type material...
11
by: Alexander Bosch | last post by:
Hi, I'm having a problem similar to the one that's stated in this KB http://support.microsoft.com/default.aspx?scid=kb;en-us;839521 When I'm posting a page to itself with the bool value as true it...
1
by: Osama Sayed | last post by:
I have a class that implements IHttpModule to handle URLs with a "RESTful" nature. It handles them according to a custom configuration section in the website's Web.Config file. My questions are:...
8
by: =?Utf-8?B?UGhpbGlw?= | last post by:
When is the IHttpModule Dispose driven ?....at application recycle time ? I developed a test HttpModule to trace INIT, BeginRequest, EndRequest and Dispose....and the Dispose never gets driven. ...
1
by: Eric Goforth | last post by:
Hello, I found a C# example on the web that used an httpmodule. I've translated it to VB.NET and the website compiles fine, but when I build the website the iHttpModule doesn't compile, I can't...
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
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
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
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...
1
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...
0
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 ...

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.