1 在这一般处理程序的方法中,当执行完逻辑后,
打印
context.Response.Write(returnValue);
context.Response.End();
结束时,成功了还是会走异常。
会报进程终止异常,处理方法,在catch (Exception)前面增加
//执行 context.Response.End();时会报进程终止的异常,下面是当这种情况下进入
catch (System.Threading.ThreadAbortException)
{
}
这样就不会进异常中了。
例:
try
{
returnValue = "{\"code\":10000,\"msg\": \"成功!\"}";
context.Response.Write(returnValue);
context.Response.End();
}
//执行 context.Response.End();时会报进程终止的异常,下面是当这种情况下进入
catch (System.Threading.ThreadAbortException)
{
}
catch (Exception)
{
returnValue = "{\"code\":10002,\"msg\": \"程序异常!\"}";
context.Response.Write(returnValue);
context.Response.End();
}