+1-888-365-2779
Try Now
More in this section

Forums / Bugs & Issues / System.Threading.ThreadAbortException

System.Threading.ThreadAbortException

10 posts, 0 answered
  1. Gérald
    Gérald avatar
    6 posts
    Registered:
    15 Jul 2010
    09 Sep 2013
    Link to this post
    Hi,

    I often get the following exception on my SiteFinity website (version 5.4.4020.0):

    System.Threading.ThreadAbortException: Thread was being aborted.
    at System.Threading.Thread.AbortInternal()  
    at System.Threading.Thread.Abort(Object stateInfo)  
    at System.Web.HttpResponse.End()  
    at System.Web.HttpResponse.Redirect(String url, Boolean endResponse, Boolean permanent)  
    at System.Web.HttpResponseWrapper.RedirectPermanent(String url, Boolean endResponse)  
    at Telerik.Sitefinity.Web.RouteHelper.SslRedirectIfNeeded(HttpContextBase httpContext, PageSiteNode node)  
    at Telerik.Sitefinity.Web.PageRouteHandler.ValidateCacheOutput(HttpContext context, Object data, HttpValidationStatus& status)  
    at System.Web.Caching.OutputCacheModule.OnEnter(Object source, EventArgs
    eventArgs)
  2. Svetla
    Svetla avatar
    36 posts
    Registered:
    07 Sep 2015
    10 Sep 2013
    Link to this post
    Hi Gérald,

    Thanks for using our services!

    This is an error stemming from Response.End not being executed. There are some resources online indicating that this may be stemming from some specific of the event not getting executed at the right event or possibly from the URL that is being constructed. I think it's the latter is true in our case, since this i. The first thing that you would need to check is what is the setting under Settings -> Advanced -> System -> Site Settings and see if Enable Non Default settings is checked or not. Make sure that SSL and the urls are configured properly according to the documentation.

    The second thing that we would need to check is which URL is the redirect being issued to and checking if this url works on SSL

    Just to clarify the context of troubleshooting this issue: here is a bit more elaboration on why I am thinking those settings are where the issue is coming from:

    A quick look at the stack trace tells me that this is coming from the route helper (Telerik.Sitefinity.Web.RouteHelper.SslRedirectIfNeeded) responsible for redirecting to an SSL page if this is required. Therefore it's safe to assume that this exception occurs only for pages where the checkbox "Require SSL" is set on pages.

    The logic of the method within the route helper is the following: if a page requires SSL then an HTTPS url is constructed and redirected to. There are two ways that Sitefinity can construct the url for HTTPS depending on settings
    • Default - simply replacing http to https in a permanent redirect stemming from the absolute URI of the page
    • Non default - based on the advanced settings we need to check what URI is being constructed.

    For some reason this redirect within the method is failing and an exception is being thrown. Some reported cases in stack overflow indicate that this type of behavior sometimes happens if for some reason the host name is different, therefore we probably need to check the settings and figure out the form of the URL that is failing.

    To test things and get the exception navigate to any page that has the "Require SSL" box enabled. You can also clean up or archive the error logs in your Log folder and do the same thing to see if there are other errors and exceptions being thrown in that context.

    I hope this information helps and let us know if this has lead you to any findings!

    Regards,
    Svetla
    Telerik
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Gérald
    Gérald avatar
    6 posts
    Registered:
    15 Jul 2010
    22 Oct 2013 in reply to Svetla
    Link to this post
    Hi,

    I still get this error on my server so I look at your code (with reflector) and I can see "RedirectPermanent(url, true)" which throws ThreadAbordException (http://stackoverflow.com/questions/2777105/why-response-redirect-causes-system-threading-threadabortexception). So I think that the error comes from your code.

    Can you confirm ?
    public static bool SslRedirectIfNeeded(HttpContextBase httpContext, PageSiteNode node)
    {
    ...
          httpContext.Response.RedirectPermanent(url, true);
    ...
    }
  4. Svetla
    Svetla avatar
    36 posts
    Registered:
    07 Sep 2015
    24 Oct 2013
    Link to this post
    Hello Gérald, 

    Yes it is coming exactly from this method, and it seems like it is related to configuration of SSL and therefore the constructed URL is not being passed correctly for some reason which we need to troubleshoot. 

    Do you have SSL enabled and configured on your site. Do any of your pages require SSL and what is the configuration there? Make sure to follow these instructions on your SSL config and double check any of the details. Also can you try opening fiddler and navigating to a page that requires SSL to see exactly what kind of behavior gets triggered there and where is the redirect issued to?

    Thank you!

     

    Regards,
    Svetla
    Telerik
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Gérald
    Gérald avatar
    6 posts
    Registered:
    15 Jul 2010
    25 Oct 2013 in reply to Svetla
    Link to this post
    Hi,

    Some pages requires SSL, and some others don't.

    My main issue is that I cannot reproduce the error; When I browse my website, everything works as expected and I don't have any error. But the fact are we get this error at least ten times a day (we save errors in Application_Error).


    Enable Non Default settings is not checked.
    The second thing that we would need to check is which URL is the redirect being issued to and checking if this url works on SSL

    I don't have this information. In Application_Error I can only get those information (+ the stacktrace)
    App Domain App Id: "******"
    App Domain App Path : "******"
    App Domain App Virtual Path : "/"
    Using Integrated Pipeline : "True"

    By you could try with those urls :
    http://www.softfluent.com
    https://www.softfluent.com/shopping-cart

    I don't find this error in the sitefinity log files.
  6. Arno
    Arno avatar
    249 posts
    Registered:
    08 Sep 2010
    10 Nov 2013
    Link to this post
    Did you find a solution to this? I am getting this error as well on 6.2.4910.
  7. Eric
    Eric avatar
    147 posts
    Registered:
    12 Nov 2007
    11 Dec 2014
    Link to this post
    It'd be nice if this were fixed. It's still happening in at least 7.1.
  8. Arno
    Arno avatar
    249 posts
    Registered:
    08 Sep 2010
    11 Dec 2014
    Link to this post

    Hi, 

    I found a work around for this in December of 2013, after a long conversation with Telerik Support. In the end they could reproduce this on their end as well. They said my work around was the way to solve it, but they would talk to the developers anyway. I don't know the outcome of that. In case you contact support, tell them to look into support ticket 762668 for details.

    In the end I wrote a recap about this issue:

    "Internally, Sitefinity is using Response.End in their Page Route Handler. For example, this occurs when redirecting from https to http. Response.End throws a ThreadAbortException by design. This exception needs to be ignored.

    Response.End only seems to throw an exception if:
    a) Sitefinity is configured to redirect from https to http for pages that need to be served via http but requested through https;
    b) output caching is enabled;
    c) the user is anonymous.
    d) the user navigates from a https to a http page for the second time.

    Projects without an Application_Error event in global.asax may not notice the exception at all."

     

    The work around is to ignore the error in the Application_Error event in global.asax:

    If (TypeOf (LastException) Is System.Threading.ThreadAbortException) Then
                    Server.ClearError()
    Else
                    ' Code to handle 404 exceptions and all other exceptions that are unexpected.
    End If

  9. Eric
    Eric avatar
    147 posts
    Registered:
    12 Nov 2007
    11 Dec 2014 in reply to Arno
    Link to this post

    Yes, I could ignore the error. But what if it's my code that's causing a ThreadAbortException? I'd like to know about it and fix it. I suppose I could check the stack trace to see if SslRedirectIfNeeded is there. But I like the practice of doing as little logic in my Application_Error as possible. This is a benign exception, but it doesn't have to happen.

    Wouldn't it be simple for Sitefinity to change their RedirectPermanent call to call ApplicationInstance.CompleteRequest() and then override the page Render and RaisePostBackEvent methods? This is how I do it when I have to do a redirect from within a try/catch.

     
    Response.RedirectPermanent(url, false);
    HttpContext.Current.ApplicationInstance.CompleteRequest();
    IsTerminating = true; // set some flag

    // This could would have to be in the codebehind of the page...
    private bool IsTerminating { get; set; }
    protected override void Render(HtmlTextWriter writer) {
    if (!IsTerminating)
    base.Render(writer);
    }
    protected override void RaisePostBackEvent(IPostBackEventHandler sourceControl, string eventArgument) {

    if (!IsTerminating)
    base.RaisePostBackEvent(sourceControl, eventArgument);
    }

  10. Arno
    Arno avatar
    249 posts
    Registered:
    08 Sep 2010
    11 Dec 2014
    Link to this post
    I totally agree that if Telerik can fix this, they should. Just ignoring errors is bad practice, but it works for now. If you contact Support I suppose they can have another look into this.
10 posts, 0 answered