我在我的asp.net 2.0和VS 2005中使用dotnetopenid。我只完成了這項工作,並且成功的身份驗證由me完成。我有一個登錄頁面,並且經過身份驗證它去food.aspx.I只想顯示food.aspx上的用戶的電子郵件地址在谷歌身份驗證後,我只做了以下工作的openid沒有別的,請告訴我我必須寫在login.aspx哪些代碼或food.aspx來顯示用戶的電子郵件地址。打開ID顯示電子郵件和用戶在網頁上的全名
<%@ Register Assembly="DotNetOpenAuth" Namespace="DotNetOpenAuth.OpenId.RelyingParty" TagPrefix="rp" %>
<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI" TagPrefix="asp" %>
<rp:OpenIdLogin ID="OID" runat=server Identifier="https://www.google.com/accounts/o8/id" ></rp:OpenIdLogin>
更新 我在login.aspx的
Protected Sub Page_Load(ByVal sender As Object, ByVal e As OpenIdEventArgs)
Dim openid As New OpenIdRelyingParty()
Dim request As IAuthenticationRequest = openid.CreateRequest("https://www.google.com/accounts/o8/id")
Dim fetch As New FetchRequest()
fetch.Attributes.AddRequired(WellKnownAttributes.Contact.Email)
request.AddExtension(fetch)
request.RedirectToProvider()
End Sub
的頁面加載事件和頁面寫了這個代碼加載Evemt Food.aspx的編寫follwoing代碼
Dim openid As OpenIdRelyingParty = New OpenIdRelyingParty
Dim response = openid.GetResponse
If (Not (response) Is Nothing) Then
Select Case (response.Status)
Case AuthenticationStatus.Authenticated
Dim fetch = response.GetExtension
Dim email As String = String.Empty
If (Not (fetch) Is Nothing) Then
email = fetch.GetAttributeValue(WellKnownAttributes.Contact.Email)
End If
FormsAuthentication.RedirectFromLoginPage(response.ClaimedIdentifier, False)
End Select
End If
但是在這一行的login.aspx頁面加載事件中仍然出現錯誤
fetch.Attributes.AddRequired(WellKnownAttributes.Contact.Email)
錯誤是
AddRequired is not a member of System.Collections.ObjectModel.KeyedCollection
(Of DotNetOpenAuth.OpenId.Extensions.AttributeExchange.AttributeRequest
我可以爲這個
請人給予回答我的問題 – 2011-12-21 05:05:48
讓這個有#1隊的人誰可以解決我的問題 – 2011-12-21 06:17:49