---
title: "Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack"  
description: "Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack"  
author: "Anonymous User"  
published: 2010-10-08  
updated: 2010-10-08  
canonical: https://www.mindstick.com/forum/25/unable-to-evaluate-expression-because-the-code-is-optimized-or-a-native-frame-is-on-top-of-the-call-stack  
category: "asp.net"  
tags: ["asp.net"]  
reading_time: 2 minutes  

---

# Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack

In my [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) I [am trying](https://answers.mindstick.com/qa/36834/which-two-programming-languages-should-i-master-in-if-i-am-trying-to-get-into-google-or-facebook) to navigate to other [page](https://www.mindstick.com/articles/13031/why-to-make-a-wikipedia-page) using \
\
Response.Redirect(Page.ResolveUrl("abc.aspx"))\
\
I [am getting](https://www.mindstick.com/forum/34179/i-am-getting-error-while-assigning-the-data-to-the-array-list) the following [error](https://yourviews.mindstick.com/view/88527/fixing-quickbooks-error-4120-reinstalling-vs-repairing)\
\
"Unable to evaluate [expression](https://www.mindstick.com/articles/1861/sqlite-expressions) because the code is optimized or a [native](https://answers.mindstick.com/qa/43346/what-did-almost-all-native-american-societies-have-in-common-in-the-1400s) [frame](https://www.mindstick.com/articles/749/html-frames) is on top of the call stack."\
\
please help me \
\
Thanks, ![Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack](http://www.mindstick.com/App_Images/HTMLEditor.icons/eusa_doh.gif)\

## Replies

### Reply by Anonymous User

Hi Chris,\
\
This problem occurs in the Response.Redirect and Server.Transfer methods because both methods call Response.End internally which ends the page execution and shifts the execution to the Application_EndRequest event in the application's event pipeline. The line of code that follows Response.End is not executed.\
\
To work around this problem, use one of the following methods: \
For Response.End, call the HttpContext.Current.ApplicationInstance.CompleteRequest method instead of Response.End to bypass the code execution to the Application_EndRequest event.

For Response.Redirect, use an overload, Response.Redirect(String url, bool endResponse) that passes false for the endResponse parameter to suppress the internal call to Response.End. For example: \
Response.Redirect ("nextpage.aspx", false);

If you use this workaround, the code that follows Response.Redirect is executed.\
For Server.Transfer, use the Server.Execute method instead.![Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack](https://www.mindstick.com/app_images/htmleditor.icons/msp_thumbup.gif)\
\
\


---

Original Source: https://www.mindstick.com/forum/25/unable-to-evaluate-expression-because-the-code-is-optimized-or-a-native-frame-is-on-top-of-the-call-stack

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
