1
我試圖實現openid概念,但失敗了。我嘗試不同的樣本表單互聯網並運行它們。當我跑他們問我提供者的認證。假設我選擇谷歌,他們將我重定向到Gmail網站。我輸入我的電子郵件和密碼並提交。而不是將我重定向到成功的登錄頁面。它將我重定向到登錄頁面,並表示登錄失敗的情況下執行。當我打開已打開的Gmail帳戶時還有一件事。我不知道爲什麼地位失敗。這一點代碼之一,我已經嘗試過。case AuthenticationStatus.Failed:在openid中使用asp.net
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DotNetOpenAuth.OpenId;
using DotNetOpenAuth.OpenId.RelyingParty;
public partial class Login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
OpenIdRelyingParty OIDRP = new OpenIdRelyingParty();
IAuthenticationResponse str = OIDRP.GetResponse();
if (str != null)
{
switch (str.Status)
{
case AuthenticationStatus.Authenticated:
NotLoggedIn.Visible = false;
Session["GoogleIdentifier"] = str.ClaimedIdentifier.ToString();
Response.Redirect("Home.aspx"); //redirect to main page of your website
break;
case AuthenticationStatus.Canceled:
lblMessage.Text = "Cancelled.";
break;
case AuthenticationStatus.Failed:
lblMessage.Text = "Login Failed.";
break;
}
}
}
protected void OpenLogin_Click(object src, CommandEventArgs e)
{
string str = e.CommandArgument.ToString();
OpenIdRelyingParty openid = new OpenIdRelyingParty();
var b = new UriBuilder(Request.Url) { Query = "" };
IAuthenticationRequest req= openid.CreateRequest(str, b.Uri, b.Uri);
req.RedirectToProvider();
}
}