473,772 Members | 2,564 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Thread was being aborted

Hi,

When I do the Login using the code below I am getting the
System.Thread.T hreadAbortExcep tion(Thread was being abortefd) on the last
line of the below code i.e.
Response.Redire ctFormsAuthenti cation.GetRedir ectUrluID,isPer sistent));

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_Cli ck(object sender, System.EventArg s e)

{

string sessionID = "";

string uID = txtUsername.Tex t;

string pwd = txtPassword.Tex t;
bool isPersistent = false; try

{

ESMLoginResultE num loginResult = ESMSecurityModu le.Login(uID, pwd, out
sessionID);

string userData = sessionID;

switch(loginRes ult)

{

case ESMLoginResultE num.OK:

{

FormsAuthentica tionTicket ticket = new
FormsAuthentica tionTicket(1,uI D,System.DateTi me.Now,System.D ateTime.Now.Add Minutes(AUTH_TI MEOUT),isPersis tent,userData,F ormsAuthenticat ion.FormsCookie Path);

// Encrypt the ticket.

string encTicket = FormsAuthentica tion.Encrypt(ti cket);

HttpCookie cookie = new
HttpCookie(Form sAuthentication .FormsCookieNam e,encTicket);

cookie.Path = FormsAuthentica tion.FormsCooki ePath;

// Create the cookie.

Response.Cookie s.Add(cookie);

// Redirect back to original URL.

Response.Redire ct(FormsAuthent ication.GetRedi rectUrl(uID,isP ersistent));

break;

}

}

}

}

Regards,

Ekta


Nov 19 '05 #1
6 5922
Enhar:
Response.Redire ct("someUrl") always throws a threadAbort exception.
Response.Reidre ct("someUrl") calls Response.Redire ct("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.Reidre cT("someUrl",
false)

or you could swollow the exception in a try/catch

try{
Response.Redire ct("someUrl")
}catch (ThreadAbortExc eption 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******** ******@TK2MSFTN GP15.phx.gbl...
Hi,

When I do the Login using the code below I am getting the
System.Thread.T hreadAbortExcep tion(Thread was being abortefd) on the last
line of the below code i.e.
Response.Redire ctFormsAuthenti cation.GetRedir ectUrluID,isPer sistent));

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_Cli ck(object sender, System.EventArg s e)

{

string sessionID = "";

string uID = txtUsername.Tex t;

string pwd = txtPassword.Tex t;
bool isPersistent = false; try

{

ESMLoginResultE num loginResult = ESMSecurityModu le.Login(uID, pwd, out
sessionID);

string userData = sessionID;

switch(loginRes ult)

{

case ESMLoginResultE num.OK:

{

FormsAuthentica tionTicket ticket = new
FormsAuthentica tionTicket(1,uI D,System.DateTi me.Now,System.D ateTime.Now.Add M
inutes(AUTH_TIM EOUT),isPersist ent,userData,Fo rmsAuthenticati on.FormsCookieP a
th);
// Encrypt the ticket.

string encTicket = FormsAuthentica tion.Encrypt(ti cket);

HttpCookie cookie = new
HttpCookie(Form sAuthentication .FormsCookieNam e,encTicket);

cookie.Path = FormsAuthentica tion.FormsCooki ePath;

// Create the cookie.

Response.Cookie s.Add(cookie);

// Redirect back to original URL.

Response.Redire ct(FormsAuthent ication.GetRedi rectUrl(uID,isP ersistent));

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


FormsAuthentica tionTicket ticket = new FormsAuthentica tionTicket(

1,

uID,

System.DateTime .Now,

System.DateTime .Now.AddMinutes (15),

isPersistent,

userData,

FormsAuthentica tion.FormsCooki ePath);

:

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

<configuratio n>

<configSections >

<section name="AppConfig uration" type="PIT.ESH.C ommon.WebConfig uration,
PITSHCommon" />

</configSections>

<system.web>

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

<customErrors mode="RemoteOnl y" />

<authenticati on mode="Forms">

<forms loginUrl="Secur ity/Login.aspx" protection="All " timeout="2" path="/"
/>
</authentication>
<authorizatio n>

<deny users="?" />

</authorization>

<trace enabled="true" requestLimit="1 0" pageOutput="fal se"
traceMode="Sort ByTime" localOnly="true " />

<sessionState mode="InProc" stateConnection String="tcpip=1 27.0.0.1:42424"
sqlConnectionSt ring="data source=127.0.0. 1;user id=sa;password= "
cookieless="fal se" timeout="2" />

<globalizatio n

requestEncoding ="utf-8"

responseEncodin g="utf-8"

culture="en-AU"

uiCulture = "en-AU"

/>

</system.web>

<AppConfigurati on>

<!-- Application Settings -->

<add key="Web.Enable PageCache" value="true" />

<add key="Web.PageCa cheExpiresInSec onds" value="3600" />

<add key="Web.Enable Ssl" value="False" />

<add key="DB.Connect ionString" value="Data Source=DEVTEST-SQL1;User
ID=sa;Password= ;Initial Catalog=Genesis 2" />

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

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

</AppConfiguratio n>

<appSettings>

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

</appSettings>

<system.runtime .remoting>

<application>

</application>

</system.runtime. remoting>

<location path="default.a spx">

<system.web>

<authorizatio n>

<allow users="?" />

</authorization>

</system.web>

</location>

<location path="Security" >

<system.web>

<authorizatio n>

<allow users="?" />

</authorization>

</system.web>

</location>

<location path="Public">

<system.web>

<authorizatio n>

<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(Obj ect sender, EventArgs e)

{

FormsAuthentica tion.SignOut();

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

{

try

{

ESMSecurityModu le.killSession( Session["SessionID"].ToString());

}

catch

{

}

}

}
WEB.CONFIG

<authenticati on 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

FormsAuthentica tionTicket ticket = new
FormsAuthentica tionTicket(1,uI D,System.DateTi me.Now,System.D ateTime.Now.Add Minutes(15),fal se,userData,For msAuthenticatio n.FormsCookiePa th);

// Encrypt the ticket.

string encTicket = FormsAuthentica tion.Encrypt(ti cket);

HttpCookie cookie = new
HttpCookie(Form sAuthentication .FormsCookieNam e,encTicket);

cookie.Path = FormsAuthentica tion.FormsCooki ePath;

// Create the cookie.

Response.Cookie s.Add(cookie);

// Redirect back to original URL.

Response.Redire ct(FormsAuthent ication.GetRedi rectUrl(uID,isP ersistent),fals e);



Regards,

Ekta
"Scott Allen" <sc***@nospam.o detocode.com> wrote in message
news:l3******** *************** *********@4ax.c om...
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
1440
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 the same application in windows 2000 professional computers that are also lot older and less effective.
3
2494
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 professional computers that are also lot older and less effective. And this error does not occure if this thread is run by console application. This asp.net gui application starts a background thread that mainly
1
4265
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. I don't get any of these errors for days, then I get a bunch all at once. I would have thought if the database call was timing out I would get a timeout error. The server is Win 2003 (under VMware), and hosts multiple asp and asp.net web...
3
3253
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. I don't get any of these errors for days, then I get a bunch all at once. I would have thought if the database call was timing out I would get a timeout error. The server is Win 2003 (under VMware), and hosts multiple asp and asp.net web...
1
662
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 form declares an instance of a data-layer class with form-level scope Protected WithEvents MyDataLayer as DataLayer -- and a new instance of the class is created in Page_Load:
5
495
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 containing information sent from the datagrid. It all works fine on my local machine but when I send it to the live server I receive "The thread was being aborted" Doing some googling suggested that I use
4
4920
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
3270
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 problem occurs when i try to show a progress bar. The screen freezes. I know i'm not the first one to ask about it. but i'm looking
2
22979
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 application and not as a service as as the installation procedure of a service on the productive system would cause a lot of administrative overhead. The thread is started in the global.asax file on startup. Strangely, after some time, the thread...
1
1192
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 one button i place in my project.That purpose is stop all functions ans close my application.In that button i call the Dispose() method.In that Dispose(0 method i call the thread.abort method.
0
9621
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10264
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10039
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9914
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7461
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4009
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3610
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.