views:

86

answers:

3

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 ...

  1. Is this a known bug?
  2. Is there a aorkaround? Should I return EmptyResult?

As far as I understand this is a bug - I submitted it in the project issue tracker.

+2  A: 

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.

Andrew Arnott
Thanks, I'll check it out.
ripper234
Does not compile.'DotNetOpenAuth.Messaging.OutgoingWebResponse' does not contain a definition for 'AsActionResponse'
ripper234
Did you add the using statement at the top of your file? And are you targeting .NET 3.5?
Andrew Arnott
A: 

Hi, I am very new to OpenID.I need the same code.But,I am using web forms.Could you please tell me how to return a response back from DotNetOpenAuth.OpenId.RelyingParty.IAuthenticationRequest.RedirectToProvider()? The system is asking me to add a namespace system.web.mvc.But,i am using a class library project.I can not use the namespace.

John Roy
A: 

Hi,

I am very new to OpenID.While using relyingParty.CreateRequest(OpenIdUrl).RedirectToProvider(),instead of ending the execution there,I need to get a webResponse back from the open ID Provider.I do not want to get back to my login site.When I use AuthenticationStatus.Authenticated(),it does not go in there.Instead stops the execution after RediorectToProvider.Any thoughts on this?

var response = relyingParty.GetResponse(); relyingParty.CreateRequest(strOpenIdUrl).RedirectToProvider(); switch (AuthenticationStatus.Authenticated) { case (response.Status()): { //do something here to get a http web response. break; } } Plus,I am using a webform here.not asp.net mvc.

John Roy
You should post this as a different question, this is not an answer.
ripper234
yes,I know that.But,this does not let me add a question unless I have some points :( .Thats y.Am sorry
John Roy