When writing a user verification function in the background today, You need to perform different page jumps based on the user's different permissions. The jump statement used is as follows:
Response. Redirect ("logonin. aspx ");
However, the following exception is always prompted:Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.
I checked it on the Internet and found it was a method problem. I used the overload method response. redirect ("logonin. aspx ", false); .
the following are the reasons for the query (not too familiar ......):
response. the end method stops page execution and converts the execution to the application_endrequest event and response in the event pipeline where the Program is applied. the Code line after end is not executed. This problem occurs in response. redirect and server. in the transfer method, both methods call response internally. end
the solution is as follows:
(1) For response. end:
Call applicationinstance. completerequest instead of response. End to skip the code execution of the application_endrequest event.
(2) For response. Redirect:
Use the overload response. Redirect (string URL, bool endresponse) to pass false to the endresponse parameter to cancel internal calls to response. End. For example:
Response. Redirect ("nextpage. aspx", false );
If this solution is used, the Code following response. Redirect will be executed.
(3) For server. Transfer:
Use the server. Execute method instead.