Getting 'Thread was being aborted.' during the login process.

  • Thread starter Thread starter James Scourange
  • Start date Start date
J

James Scourange

Guest
I am dealing with a strange issue. Our code has a login process that, if the login is successful, forces to redirect the user to a home page.

That logic works fine locally, on the test server, on the dev servers, and in production. However, just in one environment that process doesn't work. It is throwing the following exception


Thread was being aborted. at System.Threading.Thread.AbortInternal() at System.Threading.Thread.Abort(Object stateInfo) at System.Web.HttpResponse.AbortCurrentThread() at System.Web.HttpResponse.End() at System.Web.HttpResponse.Redirect(String url, Boolean endResponse, Boolean permanent) at System.Web.HttpResponse.Redirect(String url) at DRMS.login.Page_Load(Object sender, EventArgs e) in login.aspx.cs:line 116

That is extremely strange as the line 116 points just to a bracket. Can somebody please help me with code? Thank you all in advance

I did already post this question in the StackOverflow and Forums.asp.net and it was suggested to

  • Use Context.ApplicationInstance.CompleteRequest(); after the Response.redirect - didn't work
  • Use Server.Execute or use Server.Transfer instead of the Response.recirect. That allowed to get to view Public.aspx page (page that is being redirected to after the successfull login) but the authentication itself didn't happen. Thus, any other link wouldn't redirect to its corresponding page but would instead bring the user back to Login.aspx with the correcponding ReturnURL query string parameter.
  • I tried to use ThreadAbortException with (and without) Thread.ResetAbort() inside - didn't work


At this point I am at a loss and run out of ideas, especially considering the very same code with the same configurations works in other regions/boxes, such as prod region, test region, or dev region

Down below I paste an entire code with attached lines

Thank you in advance for your all the help

24 protected void Page_Load(object sender, EventArgs e)
25 {
26
27 try
28 {
29
30 //DateTime warningDateTime = new DateTime();
31 DataSet dset = null;
32 drmsda = new DRMS_Transaction.drms_dataaccess();
33
34 //Changing Web.Config variables to DB Variables
35 dset = drmsda.GetConfigVariables("Warning_Message");
36 if (dset.Tables["ConfigVariables"] != null)
37 {
38 if (dset.Tables["ConfigVariables"].Rows.Count > 0)
39 {
40 if (dset.Tables["ConfigVariables"].Rows[0]["a_expiry"].ToString() != "")
41 {
42 if (Convert.ToDateTime(dset.Tables["ConfigVariables"].Rows[0]["a_expiry"]) >= Convert.ToDateTime(drmsda.GetServerDateTime()))
43 {
44 lblWarningMessage.Visible = true;
45 lblWarningMessage.Text = dset.Tables["ConfigVariables"].Rows[0]["a_value"].ToString();
46 }
47
48 }
49 }
50 }
51
52 if (!IsPostBack)
53 {
54 if (ConfigurationManager.AppSettings["InTestingMode"].ToUpper() == "YES")
55 {
56 txtUsername.Text = "kommulas@gmail.com";
57 chkAgreement.Checked = true;
58 }
59
60 //Changing Web.Config variables to Announcement
61 dset = drmsda.GetConfigVariables("Announcement");
62 if (dset.Tables["ConfigVariables"] != null)
63 {
64 if (dset.Tables["ConfigVariables"].Rows.Count > 0)
65 {
66 if (dset.Tables["ConfigVariables"].Rows[0]["a_expiry"].ToString() != "")
67 {
68 if (Convert.ToDateTime(dset.Tables["ConfigVariables"].Rows[0]["a_expiry"]) >= Convert.ToDateTime(drmsda.GetServerDateTime()))
69 {
70 lnkAnnouncement.Visible = true;
71 lnkAnnouncement.Text = dset.Tables["ConfigVariables"].Rows[0]["a_value"].ToString();
72 lnkAnnouncement.NavigateUrl = dset.Tables["ConfigVariables"].Rows[0]["a_url"].ToString();
73 }
74
75 }
76 }
77 }
78
79 //Changing Web.Config variables to variables in database
80 dset = drmsda.GetConfigVariables("OutageMessage");
81 if (dset.Tables["ConfigVariables"] != null)
82 {
83 if (dset.Tables["ConfigVariables"].Rows.Count > 0)
84 {
85 if (dset.Tables["ConfigVariables"].Rows[0]["a_expiry"].ToString() != "")
86 {
87 if (Convert.ToDateTime(dset.Tables["ConfigVariables"].Rows[0]["a_expiry"]) >= Convert.ToDateTime(drmsda.GetServerDateTime()))
88 {
89 lblOutage.Visible = true;
90
91 lblOutage.Text = dset.Tables["ConfigVariables"].Rows[0]["a_value"].ToString();
92 }
93
94 }
95 }
96 }
97 //if (ConfigurationManager.AppSettings["TurnOnOutageMessage"].ToUpper() == "YES")
98 //{
99 // lblOutage.Visible = true;
100 // lblLineBreak.Visible = true;
101
102 // lblOutage.Text = ConfigurationManager.AppSettings["OutageMessage"] + "  ";
103 //}
104
105 string refererURL = string.Empty;
106 if (Page.Request.QueryString["ReturnURL"] != null)
107 {
108 refererURL = Page.Request.QueryString["ReturnURL"].ToString();
109 }
110 //Check to see if user was redirected because of Timeout or initial login
111 //Where "Default.aspx" is the default page for your application
112 if (refererURL != "" && refererURL != (ResolveUrl("~") + "login.aspx"))
113 {
114 //Show HTML etc showing session timeout message
115 if (refererURL == "/")
116 {
117 Response.Redirect("~/login.aspx", false);
118 Context.ApplicationInstance.CompleteRequest();
119 }
120 else if (refererURL.Length >= 26)
121 {
122 if (refererURL.Substring(0, 26).ToLower() == "/public/searchresults.aspx")
123 {
124 Response.Redirect("~/login.aspx", false);
125 Context.ApplicationInstance.CompleteRequest();
126 }
127 }
128 else
129 {
130 drmsda.InsertErrorlog("External: login.aspx.cs", "Page Load", refererURL, refererURL, "");
131 lblMessage.Text = "Session Timeout. Please login again.";
132 lblMessage.Visible = true;
133 }
134 }
135 //else
136 //// User redirected here to to initial login
137 //{
138 // lblMessage.Text = "Please login";
139 // lblMessage.Visible = true;
140
141 // //Show HTML showing initial login HTML message etc
142 //}
143
144#if (SkipVirusCheck)
145 Label2.Text = "ACCESS Application is running in Pilot Mode.<br><br>";
146 //Label2.Text = "ACCESS Application is running in Debug Mode.<br><br>";
147 //btnLogin.Text = "Debug Mode";
148 //btnLogin.BackColor = Color.Red;
149#endif
150
151 if (ConfigurationManager.AppSettings["IsSiteDown"].ToUpper() == "YES")
152 {
153 Response.Redirect("~/Message.aspx", false);
154 Context.ApplicationInstance.CompleteRequest();
155 }
156 else
157 {
158
159 //Changing Web.Config variables to variables in database
160 dset = drmsda.GetConfigVariables("View_Notice_Label_1");
161 if (dset.Tables["ConfigVariables"] != null)
162 {
163 if (dset.Tables["ConfigVariables"].Rows.Count > 0)
164 {
165 HyperLink7.Text = dset.Tables["ConfigVariables"].Rows[0]["a_value"].ToString();
166 HyperLink7.NavigateUrl = dset.Tables["ConfigVariables"].Rows[0]["a_url"].ToString();
167 HyperLinkMessage.Text = dset.Tables["ConfigVariables"].Rows[0]["a_value"].ToString();
168 HyperLinkMessage.NavigateUrl = dset.Tables["ConfigVariables"].Rows[0]["a_url"].ToString();
169 }
170 }
171 }
172 }
173 }
174 catch (Exception e3)
175 {
176 drmsda.InsertErrorlog("External: login.aspx.cs", "Page Load", e3.Source, e3.Message + " " + e3.StackTrace, "");
177 }
178 }



Continue reading...
 
Back
Top