0

以下のコードページを正常にロードしようとすると、Google認証に関するこの質問が読み込まれますが、Googleでログインのボタンをクリックすると、この行の表示エラーがデバッグされます。

でのエラー

GetExtension<FetchResponse>() 

オンライン

Var fetchResponse = Response.GetExtension<FetchResponse>()

したがって、この行の問題は何ですか..私はこの問題を検索しようとしましたが、その解決策が得られません

protected void Page_Load(object sender, EventArgs e)
    {
        OpenIdRelyingParty rp = new OpenIdRelyingParty();
        var r = rp.GetResponse();
        if (r != null)
        {
            switch (r.Status)
            {
                case AuthenticationStatus.Authenticated:
                    NotLoggedIn.Visible = false;
                    Session["GoogleIdentifier"] = r.ClaimedIdentifier.ToString();
                    Response.Redirect("Default4.aspx"); //redirect to main page of your website  
                    var fetchResponse = Response.GetExtension<FetchResponse>();
                    Session["FetchResponse"] = fetchResponse;
                    var response2 = Session["FetchResponse"] as FetchResponse;
                    // Use FormsAuthentication to tell ASP.NET that the user is now logged in,
                    // with the OpenID Claimed Identifier as their username.
                    string uname = response2.GetAttributeValue(WellKnownAttributes.Name.First) ?? "Guest";
                    FormsAuthentication.RedirectFromLoginPage(uname, false);   //(response.ClaimedIdentifier, false);
                    break;

                case AuthenticationStatus.Canceled:
                    lblAlertMsg.Text = "Cancelled.";
                    break;

                case AuthenticationStatus.Failed:
                    lblAlertMsg.Text = "Login Failed.";
                    break;
            }
        }
    }

    protected void OpenLogin_Click(object src, CommandEventArgs e)
    {
        string discoveryUri = e.CommandArgument.ToString();
        OpenIdRelyingParty openid = new OpenIdRelyingParty();
        var b = new UriBuilder(Request.Url) { Query = "" };
        //var req = openid.CreateRequest(discoveryUri, b.Uri, b.Uri);


        //var req = openid.CreateRequest(discoveryUri, b.Uri, b.Uri);
        var req = openid.CreateRequest(discoveryUri);

        // This is where you would add any OpenID extensions you wanted
        // to include in the authentication request. In this case, we are making use of OpenID Attribute Exchange 1.0
        // to fetch additional data fields from the OpenID Provider
        var fetchRequest = new FetchRequest();
        fetchRequest.Attributes.AddRequired(WellKnownAttributes.Contact.Email);
        fetchRequest.Attributes.AddRequired(WellKnownAttributes.Name.First);
        fetchRequest.Attributes.AddRequired(WellKnownAttributes.Name.Last);
        fetchRequest.Attributes.AddRequired(WellKnownAttributes.Contact.HomeAddress.Country);
        req.AddExtension(fetchRequest);


        req.RedirectToProvider();

    }
4

1 に答える 1

1

そのはず

var fetchResponse = r.GetExtension<FetchResponse>();

それ以外の

var fetchResponse = Response.GetExtension<FetchResponse>();
于 2012-08-21T12:38:42.237 に答える