views:

394

answers:

2

Hi,

I am using Dotnetopenid for my openid solution, everything is fine when using the built-in user control, but when I want to implement it programmaticaly, like the below code,

openid.Response.GetExtension<DotNetOpenId.Extensions.SimpleRegistration.ClaimsResponse>();

is always null. any idea?

    OpenIdRelyingParty openid = createRelyingParty();
 if (openid.Response != null) {
  switch (openid.Response.Status) {
   case AuthenticationStatus.Authenticated:
    // This is where you would look for any OpenID extension responses included
    // in the authentication assertion.
    // var extension = openid.Response.GetExtension<SomeExtensionResponseType>();

    // Use FormsAuthentication to tell ASP.NET that the user is now logged in,
    // with the OpenID Claimed Identifier as their username.
                State.ProfileFields = openid.Response.GetExtension<DotNetOpenId.Extensions.SimpleRegistration.ClaimsResponse>();
    FormsAuthentication.RedirectFromLoginPage(openid.Response.ClaimedIdentifier, false);
    break;
+3  A: 

getting help from Andrew

I've missed to add extension to my request before redirecting to provider. ( this step is not coded in sample files )

to do this, after creating the request object do like this:

  Dim request As IAuthenticationRequest = openid.CreateRequest(openid_identifier.Text)
        ' This is where you would add any OpenID extensions you wanted
        ' to include in the authentication request.
        ' request.AddExtension(someExtensionRequestInstance);
        Dim myclaim As New ClaimsRequest

        With myclaim
            .BirthDate = DemandLevel.Request
            .Country = DemandLevel.Request
            .Email = DemandLevel.Request
            .FullName = DemandLevel.Request
            .Gender = DemandLevel.Request
            .Language = DemandLevel.Request
            .Nickname = DemandLevel.Request
            .PostalCode = DemandLevel.Request
            .TimeZone = DemandLevel.Request

        End With


        request.AddExtension(myclaim)









        ' Send your visitor to their Provider for authentication.
        request.RedirectToProvider()

code is in vb.net

mohamadreza
Can you please point to some step by step instructions of implementing DotNetOpenId in MVC. I am a beginner with MVC and OpenId.
Picflight
@Picflight you can check here http://stackoverflow.com/questions/933884/request-for-tutorial-to-add-openid-support-to-nerddinner-asp-net-mvc-application
mohamadreza
A: 

Noted to be fixed and made clearer in next release.

David Christiansen