IDLoginStatus显示“退出”但LoggedInLiveID为False [英] IDLoginStatus shows "Sign out" but LoggedInLiveID is False

查看:112
本文介绍了IDLoginStatus显示“退出”但LoggedInLiveID为False的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用示例WebAuth代码,我点击"登录"当我的页面返回时,它显示"退出"。

但是,IDLoginStatus1.LoggedInLiveId = False和IDLoginView始终显示AnonymousTemplate而不是LoggedInIDTemplate。

一直在追逐这太过分了。

有什么想法?

鲍勃

Using the sample WebAuth code, I click on "Sign In" and when my page returns, it shows "Sign out".

But, the IDLoginStatus1.LoggedInLiveId = False and IDLoginView always shows the AnonymousTemplate rather than LoggedInIDTemplate.

Been chasing this for wayyyy too long. 

Any thoughts?

Bob

推荐答案

问。 LoggedInLiveID属性在什么时候都等于"true"。 ?

以下是ASPX示例:

Q. At what point does the LoggedInLiveID property every equal "true" ?

Here is the sample ASPX:

<%@ Page Language="vb" AutoEventWireup="true" CodeFile="default.aspx.vb" Inherits="DefaultPage" %>

<%@ Register Assembly="Microsoft.Live.ServerControls" Namespace="Microsoft.Live.ServerControls" TagPrefix="live" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <title>Windows Live ID Web Authentication Sample</title>
</head>
<body style="background-color:#ffefd5;">
    <form id="iForm" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <table border="1" cellpadding="5px">
        <tr>
            <td>
                IDLoginStatus
            </td>
            <td>
                <live:IDLoginStatus ID="IDLoginStatus1" runat="server" AllowTransparency="true" EnableViewState="true" />
            </td>
        </tr>
        <tr>
            <td>
                IDLoginStatus1.LoggedInLiveID
            </td>
            <td>
                <asp:Label ID="iLiveStatus" runat="server" Text="Label"></asp:Label>
            </td>
        </tr>
        <tr>
            <td>
                WebAuthControl
            </td>
            <td>
                <iframe id="WebAuthControl" name="WebAuthControl" src="http://login.live.com/controls/WebAuthButton.htm?appid=<%=AppId%>&style=font-size%3A+10pt%3B+font-family%3A+verdana%3B+background%3A+white%3B"
                    width="80px" height="20px" marginwidth="0" marginheight="0" align="middle" frameborder="0" scrolling="no"></iframe>
            </td>
        </tr>
        <tr>
            <td>
                UserId
            </td>
            <td>
                <%=UserId%>&nbsp;
            </td>
        </tr>
    </table>
    </form>
</body>
</html>

以及表格背后的代码:

Imports WindowsLive

Partial Public Class DefaultPage
    Inherits System.Web.UI.Page
    Private Const LoginCookieToken As String = "webauthtoken"

    Private Shared wll As New WindowsLiveLogin(True)

    Protected Shared AppId As String = wll.AppId
    Protected UserId As String

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
        'If the user token has been cached in a site cookie, attempt to process it and extract the user ID. 

        iLiveStatus.Text = IDLoginStatus1.LoggedInLiveID.ToString

        Dim req As HttpRequest = HttpContext.Current.Request
        Dim loginCookie As HttpCookie = req.Cookies(LoginCookieToken)

        If loginCookie IsNot Nothing Then
            Dim token As String = loginCookie.Value

            If (Not String.IsNullOrEmpty(token)) Then
                Dim user As WindowsLiveLogin.User = wll.ProcessToken(token)

                If user IsNot Nothing Then
                    UserId = user.Id
                End If
            End If
        End If
    End Sub
End Class



鲍勃



Bob


这篇关于IDLoginStatus显示“退出”但LoggedInLiveID为False的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆