diff options
Diffstat (limited to 'src/DotNetOpenAuth.OpenId.RelyingParty.UI/OpenId/RelyingParty/OpenIdRelyingPartyAjaxControlBase.cs')
-rw-r--r-- | src/DotNetOpenAuth.OpenId.RelyingParty.UI/OpenId/RelyingParty/OpenIdRelyingPartyAjaxControlBase.cs | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/src/DotNetOpenAuth.OpenId.RelyingParty.UI/OpenId/RelyingParty/OpenIdRelyingPartyAjaxControlBase.cs b/src/DotNetOpenAuth.OpenId.RelyingParty.UI/OpenId/RelyingParty/OpenIdRelyingPartyAjaxControlBase.cs index 0d5435d..2a14ae3 100644 --- a/src/DotNetOpenAuth.OpenId.RelyingParty.UI/OpenId/RelyingParty/OpenIdRelyingPartyAjaxControlBase.cs +++ b/src/DotNetOpenAuth.OpenId.RelyingParty.UI/OpenId/RelyingParty/OpenIdRelyingPartyAjaxControlBase.cs @@ -289,11 +289,11 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { this.Identifier = userSuppliedIdentifier; - var serializer = new JavaScriptSerializer(); - this.discoveryResult = Task.Run(async delegate { - IEnumerable<IAuthenticationRequest> requests = await this.CreateRequestsAsync(this.Identifier, CancellationToken.None); - return serializer.Serialize(await this.AjaxRelyingParty.AsJsonDiscoveryResultAsync(requests, CancellationToken.None)); - }).GetAwaiter().GetResult(); + this.Page.RegisterAsyncTask(new PageAsyncTask(async ct => { + var serializer = new JavaScriptSerializer(); + IEnumerable<IAuthenticationRequest> requests = await this.CreateRequestsAsync(this.Identifier, ct); + this.discoveryResult = serializer.Serialize(await this.AjaxRelyingParty.AsJsonDiscoveryResultAsync(requests, ct)); + })); } /// <summary> @@ -346,16 +346,18 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { // but our AJAX controls hide an old OpenID message in a postback payload, // so we deserialize it and process it when appropriate. if (this.Page.IsPostBack) { - var response = Task.Run(() => this.GetAuthenticationResponseAsync(CancellationToken.None)).GetAwaiter().GetResult(); - if (response != null && !this.AuthenticationProcessedAlready) { - // Only process messages targeted at this control. - // Note that Stateless mode causes no receiver to be indicated. - string receiver = response.GetUntrustedCallbackArgument(ReturnToReceivingControlId); - if (receiver == null || receiver == this.ClientID) { - this.ProcessResponse(response); - this.AuthenticationProcessedAlready = true; + this.Page.RegisterAsyncTask(new PageAsyncTask(async ct => { + var response = await this.GetAuthenticationResponseAsync(ct); + if (response != null && !this.AuthenticationProcessedAlready) { + // Only process messages targeted at this control. + // Note that Stateless mode causes no receiver to be indicated. + string receiver = response.GetUntrustedCallbackArgument(ReturnToReceivingControlId); + if (receiver == null || receiver == this.ClientID) { + this.ProcessResponse(response); + this.AuthenticationProcessedAlready = true; + } } - } + })); } } |