Connecting Tech Pros Worldwide Forums | Help | Site Map

Server.Transfer - very bizarre

Stan
Guest
 
Posts: n/a
#1: Nov 19 '05
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



Marina
Guest
 
Posts: n/a
#2: Nov 19 '05

re: Server.Transfer - very bizarre


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.

"Stan" <nospam@yahoo.com> wrote in message
news:eGzsNrPeFHA.1456@TK2MSFTNGP15.phx.gbl...[color=blue]
> 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
>
>[/color]


Bruce Barker
Guest
 
Posts: n/a
#3: Nov 19 '05

re: Server.Transfer - very bizarre


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)


"Stan" <nospam@yahoo.com> wrote in message
news:eGzsNrPeFHA.1456@TK2MSFTNGP15.phx.gbl...[color=blue]
> 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
>
>[/color]


Stan
Guest
 
Posts: n/a
#4: Nov 19 '05

re: Server.Transfer - very bizarre


It was working, very strange..

So what if I need both try/catch and Server.Transfer?

"Marina" <someone@nospam.com> wrote in message
news:O%232Hy$PeFHA.2888@TK2MSFTNGP15.phx.gbl...[color=blue]
> 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.
>
> "Stan" <nospam@yahoo.com> wrote in message
> news:eGzsNrPeFHA.1456@TK2MSFTNGP15.phx.gbl...[color=green]
> > 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"[/color][/color]
error[color=blue][color=green]
> > 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
> >
> >[/color]
>
>[/color]


joey.powell@topscene.com
Guest
 
Posts: n/a
#5: Nov 19 '05

re: Server.Transfer - very bizarre


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>

Closed Thread