Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Wherever I use SPUtility.Redirect in my code it works ok for the user but i see a thread abort exception in the ULS logs, the message starts with:

"ExceptionType: 'ThreadAbortException' ExceptionMessage: 'Thread was being aborted.')"

Then a few lines later in ULS i see a host of request not disposed entries starting wtih:

"An SPRequest object was not disposed before the end of this thread"

I have seen other poeple reporting the ThreadAbortException on the internet, but no one has been able to explain why this happens, or how to use SPUtility.Redirect in such a way that the exception isn't thrown. Whilst Response.Redirect(url,false) doesn't raise an exception, i still see the entries reporting that the SPRequest wasn't disposed properly. Hope you can help

share|improve this question

1 Answer 1

There's an answer on technet which explains it pretty well:

Hello!

When request is being redirected, the HttpResponse.End() method is called. The given method, in turn, calls

Thread.CurrentThread.Abort(new HttpApplication.CancelModuleException(false));

The Thread.Abort method raises ThreadAbortException in the thread where it is invoked to begin the process of terminating the thread. I mentioned about that in my blog post. So it's normal behavior.

Try to use SPRedirectFlags.DoNotEndResponse when calling SPUtility.Redirect().

share|improve this answer
    
Thank you for this, the correct solution and an explanation of the issue. I couldn't ask for more. Edit: I know this is just pointing to another article but Google brought me here. –  Vinnyq12 Jul 5 '13 at 8:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.