473,387 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Thread was being aborted

Hi,

When I do the Login using the code below I am getting the
System.Thread.ThreadAbortException(Thread was being abortefd) on the last
line of the below code i.e.
Response.RedirectFormsAuthentication.GetRedirectUr luID,isPersistent));

there is no original URL, therefore it is returning Default.aspx.

I don't know why I am getting the above exception.

private void ButtonLogin_Click(object sender, System.EventArgs e)

{

string sessionID = "";

string uID = txtUsername.Text;

string pwd = txtPassword.Text;
bool isPersistent = false; try

{

ESMLoginResultEnum loginResult = ESMSecurityModule.Login(uID, pwd, out
sessionID);

string userData = sessionID;

switch(loginResult)

{

case ESMLoginResultEnum.OK:

{

FormsAuthenticationTicket ticket = new
FormsAuthenticationTicket(1,uID,System.DateTime.No w,System.DateTime.Now.AddMinutes(AUTH_TIMEOUT),isP ersistent,userData,FormsAuthentication.FormsCookie Path);

// Encrypt the ticket.

string encTicket = FormsAuthentication.Encrypt(ticket);

HttpCookie cookie = new
HttpCookie(FormsAuthentication.FormsCookieName,enc Ticket);

cookie.Path = FormsAuthentication.FormsCookiePath;

// Create the cookie.

Response.Cookies.Add(cookie);

// Redirect back to original URL.

Response.Redirect(FormsAuthentication.GetRedirectU rl(uID,isPersistent));

break;

}

}

}

}

Regards,

Ekta


Nov 19 '05 #1
6 5865
Enhar:
Response.Redirect("someUrl") always throws a threadAbort exception.
Response.Reidrect("someUrl") calls Response.Redirect("someUrl", true)
with true meaning "end the response". So Response.End() is called which
throws that exception.

If you want, you can avoid the error by doing Response.ReidrecT("someUrl",
false)

or you could swollow the exception in a try/catch

try{
Response.Redirect("someUrl")
}catch (ThreadAbortException ex){}

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"enahar" <en****@hotmail.com> wrote in message
news:e0**************@TK2MSFTNGP15.phx.gbl...
Hi,

When I do the Login using the code below I am getting the
System.Thread.ThreadAbortException(Thread was being abortefd) on the last
line of the below code i.e.
Response.RedirectFormsAuthentication.GetRedirectUr luID,isPersistent));

there is no original URL, therefore it is returning Default.aspx.

I don't know why I am getting the above exception.

private void ButtonLogin_Click(object sender, System.EventArgs e)

{

string sessionID = "";

string uID = txtUsername.Text;

string pwd = txtPassword.Text;
bool isPersistent = false; try

{

ESMLoginResultEnum loginResult = ESMSecurityModule.Login(uID, pwd, out
sessionID);

string userData = sessionID;

switch(loginResult)

{

case ESMLoginResultEnum.OK:

{

FormsAuthenticationTicket ticket = new
FormsAuthenticationTicket(1,uID,System.DateTime.No w,System.DateTime.Now.AddM
inutes(AUTH_TIMEOUT),isPersistent,userData,FormsAu thentication.FormsCookiePa
th);
// Encrypt the ticket.

string encTicket = FormsAuthentication.Encrypt(ticket);

HttpCookie cookie = new
HttpCookie(FormsAuthentication.FormsCookieName,enc Ticket);

cookie.Path = FormsAuthentication.FormsCookiePath;

// Create the cookie.

Response.Cookies.Add(cookie);

// Redirect back to original URL.

Response.Redirect(FormsAuthentication.GetRedirectU rl(uID,isPersistent));

break;

}

}

}

}

Regards,

Ekta

Nov 19 '05 #2
Hi,

Session is still not timing out when there is no activity by the user for 15
minutes.

My web.config settings are as below.
also in the login page for the ticket I am adding 15 minutes.
What is wrong i am doing it..
Regards,
Ekta


FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(

1,

uID,

System.DateTime.Now,

System.DateTime.Now.AddMinutes(15),

isPersistent,

userData,

FormsAuthentication.FormsCookiePath);

:

<?xml version="1.0" encoding="utf-8" ?>

<configuration>

<configSections>

<section name="AppConfiguration" type="PIT.ESH.Common.WebConfiguration,
PITSHCommon" />

</configSections>

<system.web>

<compilation defaultLanguage="c#" debug="true" />

<customErrors mode="RemoteOnly" />

<authentication mode="Forms">

<forms loginUrl="Security/Login.aspx" protection="All" timeout="2" path="/"
/>
</authentication>
<authorization>

<deny users="?" />

</authorization>

<trace enabled="true" requestLimit="10" pageOutput="false"
traceMode="SortByTime" localOnly="true" />

<sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data source=127.0.0.1;user id=sa;password="
cookieless="false" timeout="2" />

<globalization

requestEncoding="utf-8"

responseEncoding="utf-8"

culture="en-AU"

uiCulture = "en-AU"

/>

</system.web>

<AppConfiguration>

<!-- Application Settings -->

<add key="Web.EnablePageCache" value="true" />

<add key="Web.PageCacheExpiresInSeconds" value="3600" />

<add key="Web.EnableSsl" value="False" />

<add key="DB.ConnectionString" value="Data Source=DEVTEST-SQL1;User
ID=sa;Password=;Initial Catalog=Genesis2" />

<add key="Copyright.Message" value="© 2001-04 Positive IT Solutions Pty
Ltd." />

<add key="Copyright.EMail" value="" />

</AppConfiguration>

<appSettings>

<add key="Copyright.EMail" value="Et*****@Postitive-IT.com.au" />

</appSettings>

<system.runtime.remoting>

<application>

</application>

</system.runtime.remoting>

<location path="default.aspx">

<system.web>

<authorization>

<allow users="?" />

</authorization>

</system.web>

</location>

<location path="Security">

<system.web>

<authorization>

<allow users="?" />

</authorization>

</system.web>

</location>

<location path="Public">

<system.web>

<authorization>

<allow users="*" />

</authorization>

</system.web>

</location>

</configuration>
Nov 19 '05 #3
On Mon, 7 Mar 2005 17:09:01 +1100, "enahar" <en****@hotmail.com>
wrote:
Hi,

Session is still not timing out when there is no activity by the user for 15
minutes.

My web.config settings are as below.
also in the login page for the ticket I am adding 15 minutes.
What is wrong i am doing it..
Regards,
Ekta


Hi Etka:

Are you testing the Session timeout or the forms authentication ticket
timeout?

--
Scott
http://www.OdeToCode.com/blogs/scott/

Nov 19 '05 #4
I am writing the following code in the web.config file and the Login.aspx.cs
for the sessiopn TimeOut and for the forms authentication ticket timeout.

Also I am writing the following code in the Body tag of the Login.aspx page

<meta http-equiv="Refresh" URL="../Security/Login.aspx>

even then Session is still not timing out when there is no activity by the
user for 15 minutes.What is wrong I am doing it.Please suggest.

code in the session_end is as follows:
protected void Session_End(Object sender, EventArgs e)

{

FormsAuthentication.SignOut();

if (Session["SessionID"] != null)

{

try

{

ESMSecurityModule.killSession(Session["SessionID"].ToString());

}

catch

{

}

}

}
WEB.CONFIG

<authentication mode="Forms">

<forms loginUrl="../Security/Login.aspx" protection="All" timeout="15"
path="/" />
</authentication>

and for the forms authentication ticket TimeOut I am writing the following
code in the Login.aspx page:

LOGIN.ASPX PAGE

FormsAuthenticationTicket ticket = new
FormsAuthenticationTicket(1,uID,System.DateTime.No w,System.DateTime.Now.AddMinutes(15),false,userDat a,FormsAuthentication.FormsCookiePath);

// Encrypt the ticket.

string encTicket = FormsAuthentication.Encrypt(ticket);

HttpCookie cookie = new
HttpCookie(FormsAuthentication.FormsCookieName,enc Ticket);

cookie.Path = FormsAuthentication.FormsCookiePath;

// Create the cookie.

Response.Cookies.Add(cookie);

// Redirect back to original URL.

Response.Redirect(FormsAuthentication.GetRedirectU rl(uID,isPersistent),false);



Regards,

Ekta
"Scott Allen" <sc***@nospam.odetocode.com> wrote in message
news:l3********************************@4ax.com...
On Mon, 7 Mar 2005 17:09:01 +1100, "enahar" <en****@hotmail.com>
wrote:
Hi,

Session is still not timing out when there is no activity by the user for
15
minutes.

My web.config settings are as below.
also in the login page for the ticket I am adding 15 minutes.
What is wrong i am doing it..
Regards,
Ekta


Hi Etka:

Are you testing the Session timeout or the forms authentication ticket
timeout?

--
Scott
http://www.OdeToCode.com/blogs/scott/

Nov 19 '05 #5
Hi enahar:

Don't relay on the Session_End event. Have you tested by hitting the
site with the browser after over 15 minutes of inactivity?

--
Scott
http://www.OdeToCode.com/blogs/scott/
Nov 19 '05 #6


Yes I have tested by hitting the
site with the browser after over 15 minutes of inactivity?

Regards
Ekta

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Johanna | last post by:
Hello, Thread was being aborted exception is thrown by my asp.net application. I hope someone could help me with this error that I get in windows 2003 server. This error has not occured with...
3
by: Johanna | last post by:
Hello, Thread was being aborted exception is thrown by IIS for my asp.net application on win2003 server. This error has not yet occured with the same asp.net application on windows 2000...
1
by: Keith F. | last post by:
Hi, I have an asp.net web app that is intermittently throwing "Thread was being aborted." errors in my data access component. This seems to occur when the app is under a heavier than normal load....
3
by: Keith F. | last post by:
Hi, I have an asp.net web app that is intermittently throwing "Thread was being aborted." errors in my data access component. This seems to occur when the app is under a heavier than normal load....
1
by: Josef K. | last post by:
I've started getting "Thread was being aborted" errors. This errormessage has me puzzled. I'm using the same very simple approach throughout the application, and it works elsewhere: -- my aspx...
5
by: Jimi | last post by:
Hi all, I have a user control which raises an event to the parent page when a person clicks on a link in a datagrid. In the event handler inside the parent page I construct a url to redirect to...
4
by: Totto | last post by:
Hi, I'm doing a server.transfer from a click event of a button, but an exception is raised with "Thread was being aborted" Anyone know why? Thanks Tor
9
by: esakal | last post by:
Hello, I'm programming an application based on CAB infrastructure in the client side (c# .net 2005) Since my application must be sequencally, i wrote all the code in the UI thread. my...
2
by: Daniel Knöpfel | last post by:
Hi I am develloping an asp.net 2.0 application. For some tasks (daily notifications to users via email), we use background threads. I rather have this task as background thread of the asp.net...
1
by: malu | last post by:
Hi I faced one exception when use the thread in c#. I start the thread in a class.Then i start the thread thru the main method constructor.In that thred i use the thred.sleep() method. Then...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.