You're running into a common deadlock problem that I describe on my blog and in a recent MSDN article.
In short, await
by default will resume its async
method inside of a captured "context", and on ASP.NET, only one thread is allowed into that "context" at a time. So when you call Wait
, you are blocking a thread inside that context, and the await
cannot enter that context when it is ready to resume the async
method. So the thread in the context is blocked at Wait
(waiting for the async
method to complete), and the async
method is blocked waiting for the context to be free... deadlock.
To fix this, you should go "async all the way". In this case, use HttpTaskAsyncHandler
instead of IHttpHandler
:
public class VisitorSignupHandler : HttpTaskAsyncHandler
{
public override async Task ProcessRequestAsync(HttpContext context)
{
//Get the user's name and email address
var UserFullName = context.Request.QueryString["name"].UrlDecode();
var UserEmailAddress = context.Request.QueryString["email"].UrlDecode();
//Save the user's information
var TaskToken = UserSignup.SaveUserSignup(UserFullName, UserEmailAddress);
await TaskToken;
....
}
}