You have created a page to give response and before it finalizes the response, you have to catch the exceptions and show the error message as response.
When you have implemented the try-catch block, you have catched an unexpected exception thrown by Response.End() which gives the message as "Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack."; well no problem at all. The exception is actually expected by IIS and you should not catch it, so the solution is as below.
try
{
//do your work here
}
catch(Exception ex)
{
//handle your response or
Response.Write(ex.Message);
}
finally
{
Response.End();
}
You may want to use Response.Redirect("Page.aspx"); in try-catch block so you have to use Response.Redirect("Page.aspx", false); as described in Microsoft Support