public static void WriteAJAXClientRedirectResponse(HttpRequest request, HttpResponse response, string location) { OSJSONResponse resp = new OSJSONResponse(); resp.AddOtherValues("__RedirectToURL", location); // write the JSON response try { WriteJavascriptResponse(request, response, FormatJSONResponseString(resp), /*flush*/ false); //this way the padding win't go on a separate chunk response.Flush(); } catch { // Ignore errors writting the response (eg: client closed tab) } }