DotNetOpenAuth无法在Live Server上运行

时间:2011-04-01 18:55:42

标签: asp.net dotnetopenauth

我参与了一个将OpenID集成到ASP.NET Web Forms中的示例应用程序。它在我的机器上本地托管时工作正常。但是,当我将应用程序上传到实时服务器时,它开始提供“登录失败”。

您可以在此处尝试示例:http://samples.bhaidar.net/openidsso

有什么想法吗?

以下是无法处理OpenID响应的源代码:

   private void HandleOpenIdProviderResponse()
    {
        // Define a new instance of OpenIdRelyingParty class
        using (var openid = new OpenIdRelyingParty())
        {
            // Get authentication response from OpenId Provider Create IAuthenticationResponse instance to be used
            // to retreive the response from OP
            var response = openid.GetResponse();

            // No authentication request was sent
            if (response == null) return;

            switch (response.Status)
            {
                // If user was authenticated
                case AuthenticationStatus.Authenticated:
                    // This is where you would look for any OpenID extension responses included
                    // in the authentication assertion.
                    var fetchResponse = response.GetExtension<FetchResponse>();

                    // Store the "Queried Fields"
                    Session["FetchResponse"] = fetchResponse;

                    // Use FormsAuthentication to tell ASP.NET that the user is now logged in,
                    // with the OpenID Claimed Identifier as their username.
                    FormsAuthentication.RedirectFromLoginPage(response.ClaimedIdentifier, false);
                    break;
                // User has cancelled the OpenID Dance
                case AuthenticationStatus.Canceled:
                    this.loginCanceledLabel.Visible = true;
                    break;
                // Authentication failed
                case AuthenticationStatus.Failed:
                    this.loginFailedLabel.Visible = true;
                    break;
            }

        }

2 个答案:

答案 0 :(得分:2)

正如Andrew建议的那样,检查异常。在我的情况下,我的生产服务器的时间和时间日期已关闭,因为票证已过期而无法进行身份验证。

答案 1 :(得分:1)

在您的实时服务器上

Turn on logging并检查它们是否有其他诊断信息。服务器上的防火墙或权限问题很可能会阻止出站HTTP请求。

当身份验证失败时,您可能会发现查看IAuthenticationResponse.Exception属性很有用。