public static SqlConnection OpenConnection() { try { if (HttpContext.Current.Session["DATABASE"] != null && HttpContext.Current.Session["USERNAME"] != null && HttpContext.Current.Session["PASSWORD"] != null && HttpContext.Current.Session["SERVERNAME"] != null) { cn = new SqlConnection("uid=" + HttpContext.Current.Session["USERNAME"].ToString() + ";pwd=" + HttpContext.Current.Session["PASSWORD"].ToString() + ";server=" + HttpContext.Current.Session["SERVERNAME"].ToString() + ";database=" + HttpContext.Current.Session["DATABASE"].ToString() + ""); if (cn.State == ConnectionState.Closed) { cn.Open(); } } else { HttpContext.Current.Response.Redirect("~/Login.aspx"); } return cn; } catch (Exception ex) { throw new Exception(ex.Message); } }
try { ... ur code } catch (ThreadAbortException ex) { }
endResponse
Response.Redirect
HttpContext.Current.Response.Redirect("~/Login.aspx", false);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)