>> try >> { >> HttpResponse response = HttpContext.Current.Response; >> Page p = HttpContext.Current.Handler as Page; >> >> if (p == null) throw new Exception("Page is not an object"); >> >> string resolvedUrl = p.ResolveUrl(url); >> >> response.Buffer = true; >> response.Status = "302 Object moved"; >> response.AddHeader("Location", resolvedUrl); >> response.Write("<HTML><Head>"); >> response.Write("<META HTTP-EQUIV=Refresh CONTENT=\"2;URL=" + resolvedUrl + "\">"); >> response.Write("<Script>window.location='" + resolvedUrl + "';</Script>"); >> response.Write("</Head>"); >> response.Write("</HTML>"); >> >> try >> { >> response.End(); >> >> //-- Remarked as the code after this method will be still executed. >> //-- We always want to stop any execution after "redirect" >> //HttpContext.Current.ApplicationInstance.CompleteRequest(); >> } >> catch >> { >> //-- To Prevent warning msg logged in event viewer >> } >> } >> catch (ThreadAbortException exc) >> { >> // This should be first catch block i.e. before generic Exception >> // This Catch block is to absorb exception thrown by Response.End >> } >> catch (Exception exc) >> { >> // Write actual error handling code here >> } >>