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);
        }
        public static void SendBackToCallingPage(string destinationPg, HttpContext context, NameValueCollection additionalParams, params string[] includedParams)
        {
            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.");
            }
            if (string.IsNullOrEmpty(destinationPg))
            {
                throw new ArgumentNullException("desinationPg", "You must specify the destination page you want to redirect to.");
            }

            string responseUrl = PageRedirect.GetUrlPefix(destinationPg);

            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            if (includedParams.Length > 0)
            {
                // We're using a delegate to define an 'anonymous' method, since the Array.ConvertAll
                //   requires that we create a 'Converter' delegate pointed to a method, but this
                //   saves the overhead of having a 'real' method call for one line of code.
                string[]    lVals = Array.ConvertAll <string, string>(includedParams, new Converter <string, string>(delegate(string val) { return(val.ToLower()); }));
                HttpRequest req   = context.Request;

                for (int i = 0; i < req.QueryString.Count; i++)
                {
                    if (lVals.Contains(req.QueryString.GetKey(i).ToLower()))
                    {
                        sb.AppendFormat("&{0}={1}", context.Server.UrlEncode(req.QueryString.GetKey(i)), context.Server.UrlEncode(req.QueryString.Get(i)));
                    }
                }
            }
            if (additionalParams != null)
            {
                for (int i = 0; i < additionalParams.Count; i++)
                {
                    sb.AppendFormat("&{0}={1}", context.Server.UrlEncode(additionalParams.GetKey(i)), context.Server.UrlEncode(additionalParams[i]));
                }
            }

            string qs = sb.ToString();

            if (!string.IsNullOrEmpty(qs))
            {
                responseUrl += "?" + qs.TrimStart('&');
            }

            context.Response.Redirect(responseUrl);
        }