public static void RedirectToPage(string destinationPg, HttpContext context, NameValueCollection qsVals) { if (context == null) { throw new ArgumentNullException("context", "You must pass the current HttpContext object for this method to function."); } else if (context.Response == null || context.Request == null) { throw new Exception("Specified HttpContext must contain both a valid request and response object."); } string redirectUrl = PageRedirect.GetUrlPefix(destinationPg); System.Text.StringBuilder sb = new System.Text.StringBuilder(); if (qsVals != null) { for (int i = 0; i < qsVals.Count; i++) { sb.AppendFormat("&{0}={1}", context.Server.UrlEncode(qsVals.Keys[i]), context.Server.UrlEncode(qsVals[i])); } } redirectUrl += "?ReturnUrl=" + PageRedirect.GetCurrentPageEncoded(context) + sb.ToString(); context.Response.Redirect(redirectUrl, true); }