Thread was being aborted

Discussion in 'ASP .Net Security' started by enahar, Mar 7, 2005.

  1. enahar

    enahar Guest

    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.GetRedirectUrluID,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.Now,System.DateTime.Now.AddMinutes(AUTH_TIMEOUT),isPersistent,userData,FormsAuthentication.FormsCookiePath);

    // Encrypt the ticket.

    string encTicket = FormsAuthentication.Encrypt(ticket);

    HttpCookie cookie = new
    HttpCookie(FormsAuthentication.FormsCookieName,encTicket);

    cookie.Path = FormsAuthentication.FormsCookiePath;

    // Create the cookie.

    Response.Cookies.Add(cookie);

    // Redirect back to original URL.

    Response.Redirect(FormsAuthentication.GetRedirectUrl(uID,isPersistent));



    break;

    }

    }

    }

    }



    Regards,

    Ekta
     
    enahar, Mar 7, 2005
    #1
    1. Advertising

  2. Hi,
    I had the same problem and I resolved it in this way.
    I modified the session as stateServer or Sql Server
    or
    I have turned off the antivirus on the directory InetPub anf for ASP_wp.exe
    and aspnet_state.exe processes.
    In fact , the antivirus, invalidate the session end the thread get aborted.
    I hope to help you
    By

    "enahar" wrote:

    > 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.GetRedirectUrluID,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.Now,System.DateTime.Now.AddMinutes(AUTH_TIMEOUT),isPersistent,userData,FormsAuthentication.FormsCookiePath);
    >
    > // Encrypt the ticket.
    >
    > string encTicket = FormsAuthentication.Encrypt(ticket);
    >
    > HttpCookie cookie = new
    > HttpCookie(FormsAuthentication.FormsCookieName,encTicket);
    >
    > cookie.Path = FormsAuthentication.FormsCookiePath;
    >
    > // Create the cookie.
    >
    > Response.Cookies.Add(cookie);
    >
    > // Redirect back to original URL.
    >
    > Response.Redirect(FormsAuthentication.GetRedirectUrl(uID,isPersistent));
    >
    >
    >
    > break;
    >
    > }
    >
    > }
    >
    > }
    >
    > }
    >
    >
    >
    > Regards,
    >
    > Ekta
    >
    >
    >
    >
    >
     
    Alessandro Zucchi, Mar 7, 2005
    #2
    1. Advertising

  3. enahar

    JayAchTee Guest

    The Redirect docs say:

    Remarks
    Redirect calls End which raises a ThreadAbortException exception upon
    completion.



    "enahar" wrote:

    > 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.GetRedirectUrluID,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.Now,System.DateTime.Now.AddMinutes(AUTH_TIMEOUT),isPersistent,userData,FormsAuthentication.FormsCookiePath);
    >
    > // Encrypt the ticket.
    >
    > string encTicket = FormsAuthentication.Encrypt(ticket);
    >
    > HttpCookie cookie = new
    > HttpCookie(FormsAuthentication.FormsCookieName,encTicket);
    >
    > cookie.Path = FormsAuthentication.FormsCookiePath;
    >
    > // Create the cookie.
    >
    > Response.Cookies.Add(cookie);
    >
    > // Redirect back to original URL.
    >
    > Response.Redirect(FormsAuthentication.GetRedirectUrl(uID,isPersistent));
    >
    >
    >
    > break;
    >
    > }
    >
    > }
    >
    > }
    >
    > }
    >
    >
    >
    > Regards,
    >
    > Ekta
    >
    >
    >
    >
    >
     
    JayAchTee, Mar 7, 2005
    #3
  4. enahar

    enahar Guest

    Hi,


    I am no more getting the exception of
    System.Thread.ThreadAbortException(Thread was being abortefd) But still the
    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.

    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.Now,System.DateTime.Now.AddMinutes(15),false,userData,FormsAuthentication.FormsCookiePath);

    // Encrypt the ticket.

    string encTicket = FormsAuthentication.Encrypt(ticket);

    HttpCookie cookie = new
    HttpCookie(FormsAuthentication.FormsCookieName,encTicket);

    cookie.Path = FormsAuthentication.FormsCookiePath;

    // Create the cookie.

    Response.Cookies.Add(cookie);

    // Redirect back to original URL.

    Response.Redirect(FormsAuthentication.GetRedirectUrl(uID,isPersistent),false);







    Regards,

    Ekta


    "Scott Allen" <> wrote in message
    news:...
    > On Mon, 7 Mar 2005 17:09:01 +1100, "enahar" <>
    > 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/
    >

    "Alessandro Zucchi" <> wrote in
    message news:...
    > Hi,
    > I had the same problem and I resolved it in this way.
    > I modified the session as stateServer or Sql Server
    > or
    > I have turned off the antivirus on the directory InetPub anf for
    > ASP_wp.exe
    > and aspnet_state.exe processes.
    > In fact , the antivirus, invalidate the session end the thread get
    > aborted.
    > I hope to help you
    > By
    >
    > "enahar" wrote:
    >
    >> 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.GetRedirectUrluID,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.Now,System.DateTime.Now.AddMinutes(AUTH_TIMEOUT),isPersistent,userData,FormsAuthentication.FormsCookiePath);
    >>
    >> // Encrypt the ticket.
    >>
    >> string encTicket = FormsAuthentication.Encrypt(ticket);
    >>
    >> HttpCookie cookie = new
    >> HttpCookie(FormsAuthentication.FormsCookieName,encTicket);
    >>
    >> cookie.Path = FormsAuthentication.FormsCookiePath;
    >>
    >> // Create the cookie.
    >>
    >> Response.Cookies.Add(cookie);
    >>
    >> // Redirect back to original URL.
    >>
    >> Response.Redirect(FormsAuthentication.GetRedirectUrl(uID,isPersistent));
    >>
    >>
    >>
    >> break;
    >>
    >> }
    >>
    >> }
    >>
    >> }
    >>
    >> }
    >>
    >>
    >>
    >> Regards,
    >>
    >> Ekta
    >>
    >>
    >>
    >>
    >>
     
    enahar, Mar 8, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Elliot M. Rodriguez
    Replies:
    1
    Views:
    2,942
    Elliot M. Rodriguez
    Jan 22, 2004
  2. Stephen Miller
    Replies:
    3
    Views:
    3,983
    Stephen Miller
    Jul 2, 2004
  3. Johanna
    Replies:
    0
    Views:
    611
    Johanna
    Oct 13, 2004
  4. =?Utf-8?B?Sm9oYW5uYQ==?=
    Replies:
    3
    Views:
    1,965
    =?Utf-8?B?Sm9oYW5uYQ==?=
    Oct 15, 2004
  5. peppermonkey
    Replies:
    1
    Views:
    249
    Gregory Brown
    Feb 10, 2007
Loading...

Share This Page