1

Why am I getting the exception While executing the Server.Transfer()...

Server.Transfer(@"~/Student/StudentSendMail.aspx?username=" + username);

{Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.}
user366312
  • 16,949
  • 65
  • 235
  • 452
  • I don't have any idea what happened. But sometimes, removing try catch block would be a solution. check it. – Anwar Chandra Aug 09 '09 at 18:40
  • This is happening when I am adding a control from an Ajax framework on the page. –  Aug 09 '09 at 18:47

2 Answers2

5

One cause of this strange error message is performing a Server.Transfer inside of a try-catch block. There are a couple of ways to handle that:

1) Add a second argument set to false like this:

Server.Transfer(@"~/Student/StudentSendMail.aspx?username=" + username, false);

2) Catch the Exception of type System.Threading.ThreadAbortException and do nothing in the catch block so the exception is ignored

3) Move the Server.Transfer to the Finally block

DOK
  • 32,337
  • 7
  • 60
  • 92