Server.Transfer results in rendering of previous page

P

Peter Nofelt

On Server.Transfer(), is there a reason why the previous page's
elements would appear on the new page? Note: this transfer is occuring
between two pages on the same server.

<Scenario>
I'm using Page.Context.Items and Server.Transfer to communicate
between two pages (lets call them page1.aspx and page2.aspx). On
postback to page1.aspx I preform a Server.Transfer() to page2.aspx.

The transfer occurs, but page2.aspx renders incorrectly. The beginning
page elements (header, start of body) from page1.aspx appear in
page2.aspx.
</Scenario>

Currently I have found little online that discusses this issue. Any
help would be appreciated.

Cheers,
Pete
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Peter said:
On Server.Transfer(), is there a reason why the previous page's
elements would appear on the new page? Note: this transfer is occuring
between two pages on the same server.

<Scenario>
I'm using Page.Context.Items and Server.Transfer to communicate
between two pages (lets call them page1.aspx and page2.aspx). On
postback to page1.aspx I preform a Server.Transfer() to page2.aspx.

The transfer occurs, but page2.aspx renders incorrectly. The beginning
page elements (header, start of body) from page1.aspx appear in
page2.aspx.
</Scenario>

Currently I have found little online that discusses this issue. Any
help would be appreciated.

Cheers,
Pete

If you output the beginning of the page during the execution of the
first file and then do a transfer, that will not clear the created
contents and start over, it will just continue to output content. That's
how a transfer works, it just continues execution of the new file, but
with the same Request and Response objects as the first file.

If you don't want any output from the first file, you simply have to
make sure that it doesn't produce any before you make the transfer.
 
A

Aidy

Or try calling Response.Clear()

Göran Andersson said:
If you output the beginning of the page during the execution of the first
file and then do a transfer, that will not clear the created contents and
start over, it will just continue to output content. That's how a transfer
works, it just continues execution of the new file, but with the same
Request and Response objects as the first file.

If you don't want any output from the first file, you simply have to make
sure that it doesn't produce any before you make the transfer.
 
P

Peter Nofelt

Thanks, this helps.
If you don't want any output from the first file, you simply have to
make sure that it doesn't produce any before you make the transfer.

When does the originating begin to emit page markup? After postback?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top