DotNetOpenAuth.OpenId.RelyingParty.IAuthenticationRequest RedirectToProvider() ThreadAbortException

557 Views Asked by At

With DotNetOpenAuth-3.4.7.11121 I receive System.Threading.ThreadAbortException when invoking DotNetOpenAuth.OpenId.RelyingParty.IAuthenticationRequest RedirectToProvider() method. My call stack looks like

" at System.Threading.Thread.AbortInternal()\r\n at System.Threading.Thread.Abort(Object stateInfo)\r\n at System.Web.HttpResponse.End()\r\n at DotNetOpenAuth.Messaging.OutgoingWebResponse.Send(HttpContext context) in c:\BuildAgent\work\a02b428f36957bca\src\DotNetOpenAuth\Messaging\OutgoingWebResponse.cs:line 161\r\n at DotNetOpenAuth.Messaging.OutgoingWebResponse.Send() in c:\BuildAgent\work\a02b428f36957bca\src\DotNetOpenAuth\Messaging\OutgoingWebResponse.cs:line 131\r\n at DotNetOpenAuth.OpenId.RelyingParty.AuthenticationRequest.RedirectToProvider()

What can I do to prevent this?

1

There are 1 best solutions below

0
On

This is by design. DotNetOpenAuth calls ASP.NET Response.Redirect(), which itself throws the ThreadAbortException in order to terminate execution on the current page. If you're using web forms, this is important because it prevents ASP.NET or the page from writing additional HTML after the DNOA response message, corrupting the message.

If you're in MVC, you can use RedirectingResponse.AsActionResult() and return that to avoid the exception.