summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--projecttemplates/MvcRelyingParty/Web.config5
-rw-r--r--projecttemplates/WebFormsRelyingParty/Web.config5
-rw-r--r--samples/InfoCardRelyingParty/web.config5
-rw-r--r--samples/OAuthAuthorizationServer/Web.config5
-rw-r--r--samples/OAuthClient/Web.config3
-rw-r--r--samples/OAuthConsumer/Web.config3
-rw-r--r--samples/OAuthResourceServer/Web.config5
-rw-r--r--samples/OAuthServiceProvider/Web.config5
-rw-r--r--samples/OpenIdProviderMvc/Web.config5
-rw-r--r--samples/OpenIdProviderWebForms/Web.config3
-rw-r--r--samples/OpenIdRelyingPartyMvc/Web.config5
-rw-r--r--samples/OpenIdRelyingPartyWebForms/Web.config5
-rw-r--r--samples/OpenIdWebRingSsoProvider/Web.config3
-rw-r--r--samples/OpenIdWebRingSsoRelyingParty/Web.config3
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs16
-rw-r--r--src/DotNetOpenAuth.OpenId.RelyingParty.UI/OpenId/RelyingParty/OpenIdAjaxTextBox.cs10
-rw-r--r--src/DotNetOpenAuth.OpenId.RelyingParty.UI/OpenId/RelyingParty/OpenIdButton.cs37
-rw-r--r--src/DotNetOpenAuth.OpenId.RelyingParty.UI/OpenId/RelyingParty/OpenIdRelyingPartyAjaxControlBase.cs30
-rw-r--r--src/DotNetOpenAuth.OpenId.RelyingParty.UI/OpenId/RelyingParty/OpenIdRelyingPartyControlBase.cs31
19 files changed, 120 insertions, 64 deletions
diff --git a/projecttemplates/MvcRelyingParty/Web.config b/projecttemplates/MvcRelyingParty/Web.config
index d59d8fb..45f8b88 100644
--- a/projecttemplates/MvcRelyingParty/Web.config
+++ b/projecttemplates/MvcRelyingParty/Web.config
@@ -133,12 +133,15 @@
<level value="INFO"/>
</logger>
</log4net>
- <appSettings/>
+ <appSettings>
+ <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
+ </appSettings>
<connectionStrings>
<!-- Remember to keep this connection string in sync with the one (if any) that appears in the log4net section. -->
<add name="DatabaseEntities" connectionString="metadata=res://*/Model.csdl|res://*/Model.ssdl|res://*/Model.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\MvcRelyingParty.mdf;Integrated Security=True;User Instance=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient"/>
</connectionStrings>
<system.web>
+ <httpRuntime targetFramework="4.5" />
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
diff --git a/projecttemplates/WebFormsRelyingParty/Web.config b/projecttemplates/WebFormsRelyingParty/Web.config
index 55179ae..14c61f9 100644
--- a/projecttemplates/WebFormsRelyingParty/Web.config
+++ b/projecttemplates/WebFormsRelyingParty/Web.config
@@ -137,12 +137,15 @@
<level value="INFO" />
</logger>
</log4net>
- <appSettings />
+ <appSettings>
+ <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
+ </appSettings>
<connectionStrings>
<!-- Remember to keep this connection string in sync with the one (if any) that appears in the log4net section. -->
<add name="DatabaseEntities" connectionString="metadata=res://*/Model.csdl|res://*/Model.ssdl|res://*/Model.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\WebFormsRelyingParty.mdf;Integrated Security=True;User Instance=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />
</connectionStrings>
<system.web>
+ <httpRuntime targetFramework="4.5" />
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
diff --git a/samples/InfoCardRelyingParty/web.config b/samples/InfoCardRelyingParty/web.config
index 835625c..510196b 100644
--- a/samples/InfoCardRelyingParty/web.config
+++ b/samples/InfoCardRelyingParty/web.config
@@ -38,10 +38,13 @@
<defaultProxy enabled="true" />
</system.net>
- <appSettings/>
+ <appSettings>
+ <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
+ </appSettings>
<connectionStrings/>
<system.web>
+ <httpRuntime targetFramework="4.5" />
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
diff --git a/samples/OAuthAuthorizationServer/Web.config b/samples/OAuthAuthorizationServer/Web.config
index 6d03f39..4e25f1e 100644
--- a/samples/OAuthAuthorizationServer/Web.config
+++ b/samples/OAuthAuthorizationServer/Web.config
@@ -75,7 +75,12 @@
providerName="System.Data.SqlClient" />
</connectionStrings>
+ <appSettings>
+ <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
+ </appSettings>
+
<system.web>
+ <httpRuntime targetFramework="4.5" />
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
diff --git a/samples/OAuthClient/Web.config b/samples/OAuthClient/Web.config
index b17ae43..a6b4f3c 100644
--- a/samples/OAuthClient/Web.config
+++ b/samples/OAuthClient/Web.config
@@ -55,10 +55,13 @@
<!-- Windows Live sign-up: http://go.microsoft.com/fwlink/p/?LinkId=193157 -->
<add key="windowsLiveAppID" value="000000004408E558" />
<add key="windowsLiveAppSecret" value="od8NVdanEIWqmlKu9hOepBE3AfUu4jCw" />
+
+ <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>
<connectionStrings/>
<system.web>
+ <httpRuntime targetFramework="4.5" />
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
diff --git a/samples/OAuthConsumer/Web.config b/samples/OAuthConsumer/Web.config
index 3330335..558515d 100644
--- a/samples/OAuthConsumer/Web.config
+++ b/samples/OAuthConsumer/Web.config
@@ -45,10 +45,13 @@
<!-- Yammer sign-up: https://www.yammer.com/client_applications/new -->
<add key="yammerConsumerKey" value=""/>
<add key="yammerConsumerSecret" value=""/>
+
+ <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>
<connectionStrings/>
<system.web>
+ <httpRuntime targetFramework="4.5" />
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
diff --git a/samples/OAuthResourceServer/Web.config b/samples/OAuthResourceServer/Web.config
index 978c20b..c7e2133 100644
--- a/samples/OAuthResourceServer/Web.config
+++ b/samples/OAuthResourceServer/Web.config
@@ -37,13 +37,16 @@
<messaging relaxSslRequirements="true" />
</dotNetOpenAuth>
- <appSettings/>
+ <appSettings>
+ <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
+ </appSettings>
<connectionStrings>
<add name="DatabaseConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
+ <httpRuntime targetFramework="4.5" />
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
diff --git a/samples/OAuthServiceProvider/Web.config b/samples/OAuthServiceProvider/Web.config
index 21fe388..674e678 100644
--- a/samples/OAuthServiceProvider/Web.config
+++ b/samples/OAuthServiceProvider/Web.config
@@ -40,13 +40,16 @@
</messaging>
</dotNetOpenAuth>
- <appSettings/>
+ <appSettings>
+ <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
+ </appSettings>
<connectionStrings>
<add name="DatabaseConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
+ <httpRuntime targetFramework="4.5" />
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
diff --git a/samples/OpenIdProviderMvc/Web.config b/samples/OpenIdProviderMvc/Web.config
index 28fffc4..b689b41 100644
--- a/samples/OpenIdProviderMvc/Web.config
+++ b/samples/OpenIdProviderMvc/Web.config
@@ -56,9 +56,12 @@
<!-- Allow DotNetOpenAuth to publish usage statistics to library authors to improve the library. -->
<reporting enabled="true" />
</dotNetOpenAuth>
- <appSettings/>
+ <appSettings>
+ <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
+ </appSettings>
<system.web>
+ <httpRuntime targetFramework="4.5" />
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
diff --git a/samples/OpenIdProviderWebForms/Web.config b/samples/OpenIdProviderWebForms/Web.config
index efed107..099d6bf 100644
--- a/samples/OpenIdProviderWebForms/Web.config
+++ b/samples/OpenIdProviderWebForms/Web.config
@@ -58,9 +58,12 @@
<appSettings>
<!-- Get your own Yubico API key here: https://upgrade.yubico.com/getapikey/ -->
<add key="YubicoAPIKey" value="3961"/>
+
+ <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>
<system.web>
+ <httpRuntime targetFramework="4.5" />
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
diff --git a/samples/OpenIdRelyingPartyMvc/Web.config b/samples/OpenIdRelyingPartyMvc/Web.config
index ba7d656..8e432b0 100644
--- a/samples/OpenIdRelyingPartyMvc/Web.config
+++ b/samples/OpenIdRelyingPartyMvc/Web.config
@@ -56,9 +56,12 @@
<reporting enabled="true" />
</dotNetOpenAuth>
- <appSettings/>
+ <appSettings>
+ <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
+ </appSettings>
<connectionStrings/>
<system.web>
+ <httpRuntime targetFramework="4.5" />
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
diff --git a/samples/OpenIdRelyingPartyWebForms/Web.config b/samples/OpenIdRelyingPartyWebForms/Web.config
index 479b285..ed7c4e0 100644
--- a/samples/OpenIdRelyingPartyWebForms/Web.config
+++ b/samples/OpenIdRelyingPartyWebForms/Web.config
@@ -66,9 +66,12 @@
<!-- Google sign-up: https://www.google.com/accounts/ManageDomains -->
<add key="googleConsumerKey" value="demo.dotnetopenauth.net"/>
<add key="googleConsumerSecret" value="5Yv1TfKm1551QrXZ9GpqepeD"/>
+
+ <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>
<system.web>
<!--<sessionState cookieless="true" />-->
+ <httpRuntime targetFramework="4.5" />
<compilation debug="true" targetFramework="4.0">
<assemblies>
<remove assembly="DotNetOpenAuth.Contracts"/>
@@ -85,7 +88,7 @@
Medium: doesn't work unless originUrl=".*" or WebPermission.Connect is extended, and Google Apps doesn't work.
Low: doesn't work because WebPermission.Connect is denied.
-->
- <trust level="Medium" originUrl=".*"/>
+ <trust level="Full" originUrl=".*"/>
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
</system.web>
diff --git a/samples/OpenIdWebRingSsoProvider/Web.config b/samples/OpenIdWebRingSsoProvider/Web.config
index 3304e97..f439bb4 100644
--- a/samples/OpenIdWebRingSsoProvider/Web.config
+++ b/samples/OpenIdWebRingSsoProvider/Web.config
@@ -57,10 +57,13 @@
<add key="whitelistedRealms" value="http://localhost:39165/;http://othertrustedrealm/"/>
<!-- Set ImplicitAuth to true when using Windows auth, or false for FormsAuthentication -->
<add key="ImplicitAuth" value="true"/>
+
+ <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>
<connectionStrings/>
<system.web>
+ <httpRuntime targetFramework="4.5" />
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
diff --git a/samples/OpenIdWebRingSsoRelyingParty/Web.config b/samples/OpenIdWebRingSsoRelyingParty/Web.config
index b64f037..b27a1c5 100644
--- a/samples/OpenIdWebRingSsoRelyingParty/Web.config
+++ b/samples/OpenIdWebRingSsoRelyingParty/Web.config
@@ -64,10 +64,13 @@
<appSettings>
<add key="SsoProviderOPIdentifier" value="http://localhost:39167/" />
<add key="SsoProviderOPEndpoint" value="http://localhost:39167/server.aspx" />
+
+ <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>
<connectionStrings/>
<system.web>
+ <httpRuntime targetFramework="4.5" />
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
diff --git a/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs b/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs
index eec7d1c..4740b4b 100644
--- a/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs
@@ -1542,18 +1542,14 @@ namespace DotNetOpenAuth.Messaging {
|| response.StatusCode == HttpStatusCode.RedirectMethod || response.StatusCode == HttpStatusCode.TemporaryRedirect,
"response",
"Redirecting response expected.");
- Requires.Argument(response.Headers.Location != null, "response", "Redirect URL header expected.");
- Requires.Argument(response.Content == null || response.Content is FormUrlEncodedContent, "response", "FormUrlEncodedContent expected");
- var builder = new UriBuilder(response.Headers.Location);
- if (response.Content != null) {
- var content = response.Content.ReadAsStringAsync();
- Assumes.True(content.IsCompleted); // cached in memory, so it should never complete asynchronously.
- var formFields = HttpUtility.ParseQueryString(content.Result).ToDictionary();
- MessagingUtilities.AppendQueryArgs(builder, formFields);
+ if (response.Headers.Location != null) {
+ return response.Headers.Location;
+ } else {
+ // Some responses are so large that they're HTML/JS self-posting pages.
+ // We can't create long URLs for those, at present.
+ throw new NotSupportedException();
}
-
- return builder.Uri;
}
/// <summary>
diff --git a/src/DotNetOpenAuth.OpenId.RelyingParty.UI/OpenId/RelyingParty/OpenIdAjaxTextBox.cs b/src/DotNetOpenAuth.OpenId.RelyingParty.UI/OpenId/RelyingParty/OpenIdAjaxTextBox.cs
index 5900e7b..4c988a8 100644
--- a/src/DotNetOpenAuth.OpenId.RelyingParty.UI/OpenId/RelyingParty/OpenIdAjaxTextBox.cs
+++ b/src/DotNetOpenAuth.OpenId.RelyingParty.UI/OpenId/RelyingParty/OpenIdAjaxTextBox.cs
@@ -740,10 +740,12 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
// If an Identifier is preset on this control, preload discovery on that identifier,
// but only if we're not already persisting an authentication result since that would
// be redundant.
- var response = Task.Run(() => this.GetAuthenticationResponseAsync(CancellationToken.None)).GetAwaiter().GetResult();
- if (this.Identifier != null && response == null) {
- this.PreloadDiscoveryAsync(this.Identifier, CancellationToken.None).Wait();
- }
+ this.Page.RegisterAsyncTask(new PageAsyncTask(async ct => {
+ var response = await this.GetAuthenticationResponseAsync(ct);
+ if (this.Identifier != null && response == null) {
+ await this.PreloadDiscoveryAsync(this.Identifier, ct);
+ }
+ }));
}
/// <summary>
diff --git a/src/DotNetOpenAuth.OpenId.RelyingParty.UI/OpenId/RelyingParty/OpenIdButton.cs b/src/DotNetOpenAuth.OpenId.RelyingParty.UI/OpenId/RelyingParty/OpenIdButton.cs
index ae962ed..958c721 100644
--- a/src/DotNetOpenAuth.OpenId.RelyingParty.UI/OpenId/RelyingParty/OpenIdButton.cs
+++ b/src/DotNetOpenAuth.OpenId.RelyingParty.UI/OpenId/RelyingParty/OpenIdButton.cs
@@ -12,6 +12,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
using System.Drawing.Design;
using System.Globalization;
using System.Linq;
+ using System.Net.Http;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
@@ -57,6 +58,8 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
#endregion
+ private HttpResponseMessage authenticationRequestRedirect;
+
/// <summary>
/// Initializes a new instance of the <see cref="OpenIdButton"/> class.
/// </summary>
@@ -119,17 +122,15 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// <param name="eventArgument">A <see cref="T:System.String"/> that represents an optional event argument to be passed to the event handler.</param>
protected override void RaisePostBackEvent(string eventArgument) {
if (!this.PrecreateRequest) {
- try {
- // We have to use Task.Run here to escape our SynchronizationContext
- Task.Run(
- async delegate {
- var requests = await this.CreateRequestsAsync(CancellationToken.None);
- var request = requests.First();
- await request.RedirectToProviderAsync(new HttpContextWrapper(this.Context));
- }).GetAwaiter().GetResult();
- } catch (InvalidOperationException ex) {
- throw ErrorUtilities.Wrap(ex, OpenIdStrings.OpenIdEndpointNotFound);
- }
+ this.Page.RegisterAsyncTask(new PageAsyncTask(async ct => {
+ try {
+ var requests = await this.CreateRequestsAsync(ct);
+ var request = requests.First();
+ await request.RedirectToProviderAsync(new HttpContextWrapper(this.Context), ct);
+ } catch (InvalidOperationException ex) {
+ throw ErrorUtilities.Wrap(ex, OpenIdStrings.OpenIdEndpointNotFound);
+ }
+ }));
}
}
@@ -142,6 +143,15 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
if (!this.DesignMode) {
ErrorUtilities.VerifyOperation(this.Identifier != null, OpenIdStrings.NoIdentifierSet);
+
+ if (this.PrecreateRequest) {
+ this.Page.RegisterAsyncTask(
+ new PageAsyncTask(
+ async ct => {
+ var requests = await this.CreateRequestsAsync(ct);
+ this.authenticationRequestRedirect = await requests.FirstOrDefault().GetRedirectingResponseAsync(ct);
+ }));
+ }
}
}
@@ -156,9 +166,8 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
} else {
string tooltip = this.Text;
if (this.PrecreateRequest && !this.DesignMode) {
- IAuthenticationRequest request = Task.Run(() => this.CreateRequestsAsync(CancellationToken.None)).GetAwaiter().GetResult().FirstOrDefault();
- if (request != null) {
- this.RenderOpenIdMessageTransmissionAsAnchorAttributesAsync(writer, request, tooltip, CancellationToken.None).Wait();
+ if (this.authenticationRequestRedirect != null) {
+ this.RenderOpenIdMessageTransmissionAsAnchorAttributes(writer, this.authenticationRequestRedirect, tooltip);
} else {
tooltip = OpenIdStrings.OpenIdEndpointNotFound;
}
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;
+ }
}
- }
+ }));
}
}
diff --git a/src/DotNetOpenAuth.OpenId.RelyingParty.UI/OpenId/RelyingParty/OpenIdRelyingPartyControlBase.cs b/src/DotNetOpenAuth.OpenId.RelyingParty.UI/OpenId/RelyingParty/OpenIdRelyingPartyControlBase.cs
index 9eb4f0e..4a52ee2 100644
--- a/src/DotNetOpenAuth.OpenId.RelyingParty.UI/OpenId/RelyingParty/OpenIdRelyingPartyControlBase.cs
+++ b/src/DotNetOpenAuth.OpenId.RelyingParty.UI/OpenId/RelyingParty/OpenIdRelyingPartyControlBase.cs
@@ -15,6 +15,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
using System.Drawing.Design;
using System.Globalization;
using System.Linq;
+ using System.Net.Http;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
@@ -643,12 +644,16 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
string receiver = this.Page.Request.QueryString[ReturnToReceivingControlId]
?? this.Page.Request.Form[ReturnToReceivingControlId];
if (receiver == this.ClientID || (receiver == null && !this.IsEmbeddedInParentOpenIdControl)) {
- var response = Task.Run(() => this.RelyingParty.GetResponseAsync(new HttpRequestWrapper(this.Context.Request), CancellationToken.None)).GetAwaiter().GetResult();
- Logger.Controls.DebugFormat(
- "The {0} control checked for an authentication response and found: {1}",
- this.ID,
- response != null ? response.Status.ToString() : "nothing");
- this.ProcessResponse(response);
+ this.Page.RegisterAsyncTask(new PageAsyncTask(
+ async ct => {
+ var response =
+ await this.RelyingParty.GetResponseAsync(new HttpRequestWrapper(this.Context.Request), ct);
+ Logger.Controls.DebugFormat(
+ "The {0} control checked for an authentication response and found: {1}",
+ this.ID,
+ response != null ? response.Status.ToString() : "nothing");
+ this.ProcessResponse(response);
+ }));
}
}
@@ -853,16 +858,15 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// <param name="writer">The HTML writer.</param>
/// <param name="request">The outgoing authentication request.</param>
/// <param name="windowStatus">The text to try to display in the status bar on mouse hover.</param>
- protected async Task RenderOpenIdMessageTransmissionAsAnchorAttributesAsync(HtmlTextWriter writer, IAuthenticationRequest request, string windowStatus, CancellationToken cancellationToken) {
+ protected void RenderOpenIdMessageTransmissionAsAnchorAttributes(HtmlTextWriter writer, HttpResponseMessage response, string windowStatus) {
Requires.NotNull(writer, "writer");
- Requires.NotNull(request, "request");
+ Requires.NotNull(response, "response");
// We render a standard HREF attribute for non-javascript browsers.
- var response = await request.GetRedirectingResponseAsync(cancellationToken);
writer.AddAttribute(HtmlTextWriterAttribute.Href, response.GetDirectUriRequest().AbsoluteUri);
// And for the Javascript ones we do the extra work to use form POST where necessary.
- writer.AddAttribute(HtmlTextWriterAttribute.Onclick, await this.CreateGetOrPostAHrefValueAsync(request, cancellationToken) + " return false;");
+ writer.AddAttribute(HtmlTextWriterAttribute.Onclick, this.CreateGetOrPostAHrefValue(response) + " return false;");
writer.AddStyleAttribute(HtmlTextWriterStyle.Cursor, "pointer");
if (!string.IsNullOrEmpty(windowStatus)) {
@@ -1012,11 +1016,10 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// </summary>
/// <param name="request">The authentication request to send.</param>
/// <returns>The javascript that should execute.</returns>
- private async Task<string> CreateGetOrPostAHrefValueAsync(IAuthenticationRequest request, CancellationToken cancellationToken) {
- Requires.NotNull(request, "request");
+ private string CreateGetOrPostAHrefValue(HttpResponseMessage requestRedirectingResponse) {
+ Requires.NotNull(requestRedirectingResponse, "requestRedirectingResponse");
- var response = await request.GetRedirectingResponseAsync(cancellationToken);
- Uri directUri = response.GetDirectUriRequest();
+ Uri directUri = requestRedirectingResponse.GetDirectUriRequest();
return "window.dnoa_internal.GetOrPost(" + MessagingUtilities.GetSafeJavascriptValue(directUri.AbsoluteUri) + ");";
}