ex = {Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.} we get this type of error when we had used Response.Redirect() method in try block.
try
{
SmtpMail.Send(loMailData);
}
catch (Exception ex)
{
Response.Redirect("failure.html");
}
Response.Redirect("thanks.html");
in this it'll throw an exception beacause we had used Response.Redirect() in try block.Solution :remove the Response.Redirect() from try block and put it after the catch block.
try{
SmtpMail.Send(loMailData);
Response.Redirect("thanks.html");
}
catch (Exception ex)
{
Response.Redirect("failure.html");
}
|