diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2011-09-28 08:00:57 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2011-09-28 08:38:58 -0700 |
commit | 1e2f941bcdb7bfba15e90b78b19487c8c3e91be3 (patch) | |
tree | 86be80a5300096a9b2560c2851943794daf72ca5 | |
parent | d1ba5762185773b1f75a4dee03a0a203530b2300 (diff) | |
download | DotNetOpenAuth-1e2f941bcdb7bfba15e90b78b19487c8c3e91be3.zip DotNetOpenAuth-1e2f941bcdb7bfba15e90b78b19487c8c3e91be3.tar.gz DotNetOpenAuth-1e2f941bcdb7bfba15e90b78b19487c8c3e91be3.tar.bz2 |
Reverted part of commit 2704b0fb445.
Reverses some of the Send->Respond changes made that are or may be invoked from ASP.NET web forms, since web forms will render HTML after the end of the protocol message.
12 files changed, 30 insertions, 14 deletions
diff --git a/samples/DotNetOpenAuth.ApplicationBlock/GoogleConsumer.cs b/samples/DotNetOpenAuth.ApplicationBlock/GoogleConsumer.cs index 1861dbc..474a569 100644 --- a/samples/DotNetOpenAuth.ApplicationBlock/GoogleConsumer.cs +++ b/samples/DotNetOpenAuth.ApplicationBlock/GoogleConsumer.cs @@ -182,7 +182,7 @@ namespace DotNetOpenAuth.ApplicationBlock { }; Uri callback = Util.GetCallbackUrlFromContext(); var request = consumer.PrepareRequestUserAuthorization(callback, extraParameters, null); - consumer.Channel.Respond(request); + consumer.Channel.Send(request); } /// <summary> diff --git a/samples/OAuthClient/OAuthClient.csproj b/samples/OAuthClient/OAuthClient.csproj index 7745c24..e857351 100644 --- a/samples/OAuthClient/OAuthClient.csproj +++ b/samples/OAuthClient/OAuthClient.csproj @@ -15,6 +15,7 @@ <AssemblyName>OAuthClient</AssemblyName> <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> <TargetFrameworkProfile /> + <UseIISExpress>false</UseIISExpress> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> @@ -107,6 +108,7 @@ </Compile> <Compile Include="SampleWcf2.aspx.cs"> <DependentUpon>SampleWcf2.aspx</DependentUpon> + <SubType>ASPXCodeBehind</SubType> </Compile> <Compile Include="GoogleApps2Legged.aspx.cs"> <DependentUpon>GoogleApps2Legged.aspx</DependentUpon> diff --git a/samples/OAuthClient/SignInWithTwitter.aspx.cs b/samples/OAuthClient/SignInWithTwitter.aspx.cs index 4268c7f..04b302c 100644 --- a/samples/OAuthClient/SignInWithTwitter.aspx.cs +++ b/samples/OAuthClient/SignInWithTwitter.aspx.cs @@ -33,7 +33,7 @@ } protected void signInButton_Click(object sender, ImageClickEventArgs e) { - TwitterConsumer.StartSignInWithTwitter(this.forceLoginCheckbox.Checked).Respond(); + TwitterConsumer.StartSignInWithTwitter(this.forceLoginCheckbox.Checked).Send(); } } }
\ No newline at end of file diff --git a/samples/OAuthClient/Twitter.aspx.cs b/samples/OAuthClient/Twitter.aspx.cs index 03824a8..9c0cb9a 100644 --- a/samples/OAuthClient/Twitter.aspx.cs +++ b/samples/OAuthClient/Twitter.aspx.cs @@ -47,7 +47,7 @@ this.AccessToken = accessTokenResponse.AccessToken; } else if (this.AccessToken == null) { // If we don't yet have access, immediately request it. - twitter.Channel.Respond(twitter.PrepareRequestUserAuthorization()); + twitter.Channel.Send(twitter.PrepareRequestUserAuthorization()); } } } diff --git a/samples/OpenIdProviderWebForms/Default.aspx.cs b/samples/OpenIdProviderWebForms/Default.aspx.cs index 81e15a5..4843639 100644 --- a/samples/OpenIdProviderWebForms/Default.aspx.cs +++ b/samples/OpenIdProviderWebForms/Default.aspx.cs @@ -37,7 +37,7 @@ try { // Send user input through identifier parser so we accept more free-form input. string rpSite = Identifier.Parse(relyingPartyRealm); - op.PrepareUnsolicitedAssertion(providerEndpoint, rpSite, Util.BuildIdentityUrl(), Util.BuildIdentityUrl()).Respond(); + op.PrepareUnsolicitedAssertion(providerEndpoint, rpSite, Util.BuildIdentityUrl(), Util.BuildIdentityUrl()).Send(); } catch (ProtocolException ex) { Label errorLabel = (Label)this.loginView.FindControl("errorLabel"); errorLabel.Visible = true; diff --git a/src/DotNetOpenAuth/Messaging/Channel.cs b/src/DotNetOpenAuth/Messaging/Channel.cs index bff395b..872fc1c 100644 --- a/src/DotNetOpenAuth/Messaging/Channel.cs +++ b/src/DotNetOpenAuth/Messaging/Channel.cs @@ -298,7 +298,7 @@ namespace DotNetOpenAuth.Messaging { /// <remarks> /// Requires an HttpContext.Current context. /// </remarks> - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use the Respond method instead, and prepare for execution to continue on this page beyond the call to Respond.")] + [EditorBrowsable(EditorBrowsableState.Never)] public void Send(IProtocolMessage message) { Contract.Requires<InvalidOperationException>(HttpContext.Current != null, MessagingStrings.CurrentHttpContextRequired); Contract.Requires<ArgumentNullException>(message != null); @@ -309,10 +309,14 @@ namespace DotNetOpenAuth.Messaging { /// Sends an indirect message (either a request or response) /// or direct message response for transmission to a remote party /// and skips most of the remaining ASP.NET request handling pipeline. + /// Not safe to call from ASP.NET web forms. /// </summary> /// <param name="message">The one-way message to send</param> /// <remarks> /// Requires an HttpContext.Current context. + /// This call is not safe to make from an ASP.NET web form (.aspx file or code-behind) because + /// ASP.NET will render HTML after the protocol message has been sent, which will corrupt the response. + /// Use the <see cref="Send"/> method instead for web forms. /// </remarks> public void Respond(IProtocolMessage message) { Contract.Requires<InvalidOperationException>(HttpContext.Current != null, MessagingStrings.CurrentHttpContextRequired); diff --git a/src/DotNetOpenAuth/Messaging/OutgoingWebResponse.cs b/src/DotNetOpenAuth/Messaging/OutgoingWebResponse.cs index b4bc22d..d9cedf6 100644 --- a/src/DotNetOpenAuth/Messaging/OutgoingWebResponse.cs +++ b/src/DotNetOpenAuth/Messaging/OutgoingWebResponse.cs @@ -126,7 +126,7 @@ namespace DotNetOpenAuth.Messaging { /// <remarks> /// Requires a current HttpContext. /// </remarks> - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use the Respond method instead, and prepare for execution to continue on this page beyond the call to Respond.")] + [EditorBrowsable(EditorBrowsableState.Never)] public virtual void Send() { Contract.Requires<InvalidOperationException>(HttpContext.Current != null && HttpContext.Current.Request != null, MessagingStrings.HttpContextRequired); @@ -140,7 +140,7 @@ namespace DotNetOpenAuth.Messaging { /// <param name="context">The context of the HTTP request whose response should be set. /// Typically this is <see cref="HttpContext.Current"/>.</param> /// <exception cref="ThreadAbortException">Typically thrown by ASP.NET in order to prevent additional data from the page being sent to the client and corrupting the response.</exception> - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use the Respond method instead, and prepare for execution to continue on this page beyond the call to Respond.")] + [EditorBrowsable(EditorBrowsableState.Never)] public virtual void Send(HttpContext context) { this.Respond(context, true); } @@ -149,9 +149,13 @@ namespace DotNetOpenAuth.Messaging { /// Automatically sends the appropriate response to the user agent /// and signals ASP.NET to short-circuit the page execution pipeline /// now that the response has been completed. + /// Not safe to call from ASP.NET web forms. /// </summary> /// <remarks> /// Requires a current HttpContext. + /// This call is not safe to make from an ASP.NET web form (.aspx file or code-behind) because + /// ASP.NET will render HTML after the protocol message has been sent, which will corrupt the response. + /// Use the <see cref="Send"/> method instead for web forms. /// </remarks> public virtual void Respond() { Contract.Requires<InvalidOperationException>(HttpContext.Current != null && HttpContext.Current.Request != null, MessagingStrings.HttpContextRequired); @@ -163,9 +167,15 @@ namespace DotNetOpenAuth.Messaging { /// Automatically sends the appropriate response to the user agent /// and signals ASP.NET to short-circuit the page execution pipeline /// now that the response has been completed. + /// Not safe to call from ASP.NET web forms. /// </summary> /// <param name="context">The context of the HTTP request whose response should be set. /// Typically this is <see cref="HttpContext.Current"/>.</param> + /// <remarks> + /// This call is not safe to make from an ASP.NET web form (.aspx file or code-behind) because + /// ASP.NET will render HTML after the protocol message has been sent, which will corrupt the response. + /// Use the <see cref="Send"/> method instead for web forms. + /// </remarks> public virtual void Respond(HttpContext context) { Contract.Requires<ArgumentNullException>(context != null); diff --git a/src/DotNetOpenAuth/OAuth2/WebServerClient.cs b/src/DotNetOpenAuth/OAuth2/WebServerClient.cs index a6fae13..0063ae0 100644 --- a/src/DotNetOpenAuth/OAuth2/WebServerClient.cs +++ b/src/DotNetOpenAuth/OAuth2/WebServerClient.cs @@ -45,7 +45,7 @@ namespace DotNetOpenAuth.OAuth2 { var authorizationState = new AuthorizationState(scope) { Callback = returnTo, }; - this.PrepareRequestUserAuthorization(authorizationState, state).Respond(); + this.PrepareRequestUserAuthorization(authorizationState, state).Send(); } /// <summary> diff --git a/src/DotNetOpenAuth/OpenId/Provider/OpenIdProvider.cs b/src/DotNetOpenAuth/OpenId/Provider/OpenIdProvider.cs index 58dfc2f..dbab28b 100644 --- a/src/DotNetOpenAuth/OpenId/Provider/OpenIdProvider.cs +++ b/src/DotNetOpenAuth/OpenId/Provider/OpenIdProvider.cs @@ -326,7 +326,7 @@ namespace DotNetOpenAuth.OpenId.Provider { /// </remarks> /// <exception cref="InvalidOperationException">Thrown if <see cref="IRequest.IsResponseReady"/> is <c>false</c>.</exception> [SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily", Justification = "Code Contract requires that we cast early.")] - [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use the Respond method instead, and prepare for execution to continue on this page beyond the call to Respond.")] + [EditorBrowsable(EditorBrowsableState.Never)] public void SendResponse(IRequest request) { Contract.Requires<InvalidOperationException>(HttpContext.Current != null, MessagingStrings.CurrentHttpContextRequired); Contract.Requires<ArgumentNullException>(request != null); @@ -397,7 +397,7 @@ namespace DotNetOpenAuth.OpenId.Provider { Contract.Requires<ArgumentNullException>(claimedIdentifier != null); Contract.Requires<ArgumentNullException>(localIdentifier != null); - this.PrepareUnsolicitedAssertion(providerEndpoint, relyingPartyRealm, claimedIdentifier, localIdentifier, extensions).Respond(); + this.PrepareUnsolicitedAssertion(providerEndpoint, relyingPartyRealm, claimedIdentifier, localIdentifier, extensions).Send(); } /// <summary> diff --git a/src/DotNetOpenAuth/OpenId/Provider/ProviderEndpoint.cs b/src/DotNetOpenAuth/OpenId/Provider/ProviderEndpoint.cs index 821d95c..4a90843 100644 --- a/src/DotNetOpenAuth/OpenId/Provider/ProviderEndpoint.cs +++ b/src/DotNetOpenAuth/OpenId/Provider/ProviderEndpoint.cs @@ -180,7 +180,7 @@ namespace DotNetOpenAuth.OpenId.Provider { public static void SendResponse() { var pendingRequest = PendingRequest; PendingRequest = null; - Provider.Respond(pendingRequest); + Provider.SendResponse(pendingRequest); } /// <summary> @@ -222,8 +222,8 @@ namespace DotNetOpenAuth.OpenId.Provider { } } if (request.IsResponseReady) { - Provider.Respond(request); PendingAuthenticationRequest = null; + Provider.SendResponse(request); } } } diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/AuthenticationRequest.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/AuthenticationRequest.cs index 8bbf04f..8d8f0da 100644 --- a/src/DotNetOpenAuth/OpenId/RelyingParty/AuthenticationRequest.cs +++ b/src/DotNetOpenAuth/OpenId/RelyingParty/AuthenticationRequest.cs @@ -300,7 +300,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { /// This method requires an ASP.NET HttpContext. /// </remarks> public void RedirectToProvider() { - this.RedirectingResponse.Respond(); + this.RedirectingResponse.Send(); } #endregion diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingPartyAjaxControlBase.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingPartyAjaxControlBase.cs index 551534a..866f942 100644 --- a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingPartyAjaxControlBase.cs +++ b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingPartyAjaxControlBase.cs @@ -428,7 +428,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { this.RelyingParty.Channel.GetRequestFromContext(), callback); - response.Respond(); + response.Send(); } /// <summary> |