Server.Transfer - very bizarre

S

Stan

This code has been working for a long time:

try
{
Server.Transfer ("Order.aspx");
}
catch (Exception ex)
{
///
}

Now, all of the sudden, the page started generating "Thread aborted" error
message.

Here is what I found -

1) the exception occurs on the main page after Server.Transfer

2) If I comment out try / catch block (!!!) it works fine (!)

I tried to do Server.Transfer ("Order.aspx", true) or Server.Transfer
("Order.aspx", false) - same result.

Why in the world it would do that?

Thanks,

-Stan
 
M

Marina

This is the designed and documented behavior. The ASP.NET runtime catches
this exception and does the appropriate transfer. Same goes for
Respone.Redirect.

It is hard to believe that this is was working any differently before.
 
B

Bruce Barker

Server.Transfer alway genrates an abort. this is how it stops the processing
of the current thread, so the current page will not overwrite the output
generated by the transfered page (they are writing to the same output
stream). if you catch exceptions, don't catch thread abort

-- bruce (sqlwork.com)
 
J

joey.powell

I don't know about Server.Transfer, but you can modify the behavior on
Response.Redirect. If you look at the overrides for it, you will see an
optional, boolean second value that controls whether or not the current
page continues to be processed on the redirect.

It would go something like this...

this.Response.Redirect("Order.aspx",false);

You might want to check it out.

JP>
 

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,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top