public static void RedirectErr(TextWriter sw) { if (sw != null) { Err.Redirect(sw); _errorWriter = sc.Error; sc.SetError(sw); IsErrorRedirected = true; } else { Err.Redirect((TextWriter)null); sc.SetError(_errorWriter); _errorWriter = null; IsErrorRedirected = false; } }