473,387 Members | 1,925 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.

Server.Transfer doesn't trigger PreInit event?

"Server.Transfer(Request.FilePath);" make server re-evaluate current
page. In debugger, I found that though the page's OnPreInit is called,
delegates attached in HttpModule is not executed. Why ASP.NET is
designed in such a way?

To make the page executed from scratch, I have to use
Resposne.Redirect(Request.FilePath), but this will waste a networking
roundtrip.

Apr 29 '07 #1
3 2480
Thats because your already within the bounds of the asp.net request pipeline
and by using transfer your effectively saying you want to stay within the
pipeline, all your really doing is transferring the page request to a
sub-request not intiating a new one. Redirtect takes you out of the asp.net
pipeline and forces a new request, hence resulting in the behaviour you
need.

Regards

John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog
"Morgan Cheng" <mo************@gmail.comwrote in message
news:11*********************@y5g2000hsa.googlegrou ps.com...
"Server.Transfer(Request.FilePath);" make server re-evaluate current
page. In debugger, I found that though the page's OnPreInit is called,
delegates attached in HttpModule is not executed. Why ASP.NET is
designed in such a way?

To make the page executed from scratch, I have to use
Resposne.Redirect(Request.FilePath), but this will waste a networking
roundtrip.

Apr 29 '07 #2
I tried to Server.Transfer to another aspx page in same server. The
PreInit event is still not triggerred.
So, we cannot put page related stuff in PreInit handler, right?


On Apr 29, 9:10 pm, "John Timney \(MVP\)"
<x_j...@timney.eclipse.co.ukwrote:
Thats because your already within the bounds of the asp.net request pipeline
and by using transfer your effectively saying you want to stay within the
pipeline, all your really doing is transferring the page request to a
sub-request not intiating a new one. Redirtect takes you out of the asp.net
pipeline and forces a new request, hence resulting in the behaviour you
need.

Regards

John Timney (MVP)http://www.johntimney.comhttp://www.johntimney.com/blog

"Morgan Cheng" <morgan.chen...@gmail.comwrote in message

news:11*********************@y5g2000hsa.googlegrou ps.com...
"Server.Transfer(Request.FilePath);" make server re-evaluate current
page. In debugger, I found that though the page's OnPreInit is called,
delegates attached in HttpModule is not executed. Why ASP.NET is
designed in such a way?
To make the page executed from scratch, I have to use
Resposne.Redirect(Request.FilePath), but this will waste a networking
roundtrip.

Apr 30 '07 #3
No - I dont think you can as you are not re-entering the event pipeline at
the start of a request

Regards

John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog
"Morgan Cheng" <mo************@gmail.comwrote in message
news:11**********************@n76g2000hsh.googlegr oups.com...
>I tried to Server.Transfer to another aspx page in same server. The
PreInit event is still not triggerred.
So, we cannot put page related stuff in PreInit handler, right?


On Apr 29, 9:10 pm, "John Timney \(MVP\)"
<x_j...@timney.eclipse.co.ukwrote:
>Thats because your already within the bounds of the asp.net request
pipeline
and by using transfer your effectively saying you want to stay within the
pipeline, all your really doing is transferring the page request to a
sub-request not intiating a new one. Redirtect takes you out of the
asp.net
pipeline and forces a new request, hence resulting in the behaviour you
need.

Regards

John Timney (MVP)http://www.johntimney.comhttp://www.johntimney.com/blog

"Morgan Cheng" <morgan.chen...@gmail.comwrote in message

news:11*********************@y5g2000hsa.googlegro ups.com...
"Server.Transfer(Request.FilePath);" make server re-evaluate current
page. In debugger, I found that though the page's OnPreInit is called,
delegates attached in HttpModule is not executed. Why ASP.NET is
designed in such a way?
To make the page executed from scratch, I have to use
Resposne.Redirect(Request.FilePath), but this will waste a networking
roundtrip.


Apr 30 '07 #4

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

Similar topics

0
by: jespey | last post by:
I have a handler that takes an incoming request and does aserver.transfer to an appropriate aspx page. I then usejavascript in the onSubmit for the form to change action to theoriginally requested...
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...
7
by: kaburke | last post by:
Is there a way to make a page at the receiving end of a Server.Transfer think that the request is a Postback? (When I say "think it is a Postback," I mean I want the page to go through the ENTIRE...
9
by: Marcelo Cabrera | last post by:
Hi, I have a user control that in turn creates a bunch of webcontrols dynamically and handles the events these webcontrols raise. It used to work fine on ASP .Net 1.1 but when compiled on 2.0 it...
5
by: Richard | last post by:
I've developed a small ASPX template framework (based on Chun Li's article on CodeProject: http://www.codeproject.com/aspnet/headerfooter.asp#xx849313xx) which uses a IHttpModule to apply...
4
by: David Veeneman | last post by:
I want to programmatically create some POST data on a web server, then pass that data to another web page that the server calls, using Server.Transfer(). What's the best way to do that? I'm...
1
by: Rachel | last post by:
We recently upgraded to ASP.NET 2 AJAX Beta 2 an since we are encountering the following problem: STEPS: 1- navigate to a page containing a UpdatePanel using SERVER.TRANSFER 2- click on a...
0
by: Rahul | last post by:
this is my code in preinit event I have "hlinkAdd" as hyperlink web control and i am using a master page, and below code is of content page preinit event. Protected Sub Page_PreInit(ByVal sender...
1
by: scarng | last post by:
I have a form that has multiple tabs. Each tab contains specific information for the record chosen. One Tab has a function that returns the distinct record from another table based on the initial...
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:
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
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
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
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,...

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.