The method DotNetOpenAuth.OpenId.RelyingParty.IAuthenticationRequest.RedirectToProvider()
is documented never to return:
Redirects the user agent to the provider for authentication. Execution of the current page terminates after this call.
However, it does return under the latest implementation (3.4.3). I'm using the following code:
using (var relayingParty = new OpenIdRelyingParty())
{
var response = relayingParty.GetResponse();
if (response == null)
{
// Stage 2: user submitting Identifier
var openId = Request.Form["openId"];
relayingParty.CreateRequest(openId).RedirectToProvider();
throw new Exception("Never gets here");
}
...
}
(The line with "Never gets here" is reached). I need to return an ActionResult from this method ...
As far as I understand this is a bug - I submitted it in the project issue tracker.
Since you're using ASP.NET MVC, you should use this code:
using DotNetOpenAuth.Messaging; // required for the extension method to work
return relyingParty.CreateRequest(openid).RedirectingResponse.AsActionResult();
Apparently ASP.NET usually throws an exception as a result of the RedirectToProvider()
call, but not always. But the above code will work and is more MVC friendly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With