Because the code has been optimized or the local framework is located on the call stack, the expression value cannot be calculated ., Stack expression
Preface
When I was working on a project in the previous period, I encountered problems such as questions. Now I have been working for a while. I forgot the specific situation. Although I found a solution, however, I still did not figure out the reason for this situation. I found the answer at the help support center of Microsoft, so I would like to record it to avoid forgetting it.
Symptom
UseResponse. End (), Response. Redirect ()OrServer. Transfer ()Method.ThreadAbortExceptionException. You can useTry-catchTo capture this exception. ProjectResponse. Redirect ()The user successfully logs on to a page, and fails to jump to a page (there are dual-open, login timeout, and other verification in the middle ). Running error:The expression value cannot be calculated because the code has been optimized or the local framework is located on the call stack.
Cause
Response. End ():End page execution and switch execution to the event pipeline of the applicationApplication_EndRequestEvent,Response. End ()Subsequent code lines will not be executed;
Response. Redirect ()AndServer. Transfer ()Both methods are called internally.Response. End ();
Solution
Original reference address: Https://support.microsoft.com/zh-cn/kb/312629