As we know , Server.Transfer throws ThreadAbortException when executed.
Also , ThreadAbortException inherits Exception :

So why the exception wont enter the catch block in :
try
{
Server.Transfer("NoPremissionSell.aspx");
}
catch (Exception e)
{ }
while it will in :
try
{
Server.Transfer("NoPremissionSell.aspx");
}
catch (ThreadAbortException e)
{ }
This is working in both 2 scenarios. I don't know why it didnt work before. please ignore.
sorry for misleading.
A number of exception types are treated differently by the .NET runtime (the Command Language Infrastructure, CLI, that underlies the execution of assemblies).
Eg. StackOverflowException cannot be caught at all by .NET code.
The reason for this depends on the exception. In the case of StackOverflowException because the CLI cannot guarantee the correctness of the state of the process.
In the case of a ThreadAbortException the special treatment is because while it can be caught it must be re-thrown (automatically) so the thread will end.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With