Server.Transfer results in rendering of previous page

  • Thread starter Thread starter Peter Nofelt
  • Start date Start date
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
 
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.
 
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.
 
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?
 
Back
Top