Error de Javascript al usar la biblioteca del lado del cliente de Messenger Connect en ASP.NET


Estoy teniendo un problema implementando la nueva funcionalidad de Messenger Connect dentro de un sitio existente de Sitefinity para habilitar los inicios de sesión de los clientes utilizando Live IDs.

Es decir, cuando estoy usando el siguiente código para implementar la funcionalidad del lado del cliente:

<head runat="server">
  <script type="text/javascript" src="http://js.live.net/4.1/loader.js"></script>
</head>
<body>
  <form runat="server" id="form1">
    <asp:ScriptManager ID="ScriptManager1" runat="server"/>
    <wl:app
        client-id="<%= ConfigurationManager.AppSettings["wl_wrap_client_id"] %>"
        scope="WL_Profiles.View"
        callback-url="<%= ConfigurationManager.AppSettings["wl_wrap_client_callback"] %>?wl_session_id=<%=SessionId %>"
        channel-url="/channel.htm">
    </wl:app>

... Tengo tres errores en Firebug que no puedo identificar correctamente:

Sys.ArgumentTypeException: Objeto de tipo ' Sys._Application' no puede ser convertido al tipo 'Sys.Imposible". Nombre del parámetro: objeto

(en ScriptResource.axd?d=.... línea 4993)

Sys.Aplicación._doInitialize no es un función

(en MicrosoftAjaxBase.js line 1)

Sys.InvalidOperationException: El script ' MicrosoftAjaxGlobalization.js" ha sido referenciado varias veces. Si hacer referencia a scripts de Microsoft AJAX explícitamente, establecer el MicrosoftAjaxMode propiedad del ScriptManager a Expresa.

(en ScriptResource.axd?d=.... línea 984)

Los errores solo se activan cuando incluyo el script loader.js desde js.live.net.

EDITAR : Parece que los errores no se activan necesariamente en ese orden. Actualizar la página parece barajar esos errores y/o introducir otros, como un Sys.ParameterCountException en ScriptResource.axd?... en la línea 1842, por ejemplo.

Author: Chris Baxter, 2010-11-18

1 answers

Hey, probé algunas combinaciones aquí, y la que funcionó fue:

1) Establezca la propiedad ScriptMode del ScriptManager en Release ;

2) Cargue la biblioteca MSN en el evento CodeBehind Page_Load, usando la clase ClientScript:

protected void Page_Load(object sender, EventArgs e)
{
    ClientScript.RegisterClientScriptInclude(this.GetType(), "live", "http://js.live.net/4.0/loader.js");
}

Firebug ya no muestra ningún error, y en mi caso, la ventana de autenticación se abre como se desea.

Espero que ayude!

EDITAR

Como dije antes, aquí sigue todo el código que uso para evite este problema:

por Defecto.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wl="http://apis.live.net/js/2010">
<head>
    <title>SignIn Example</title>
    <script type="text/javascript">
        function appLoaded(appLoadedEventArgs) {
        }
        function signInCallback(signInCompletedEventArgs) {
            if (signInCompletedEventArgs.get_resultCode() === Microsoft.Live.AsyncResultCode.success)
            {
                alert('Sign-in successful.');
            }
            else
            {
                alert('Sign-in failed.');
            }
        }
    </script>
</head>
<body>
    <form runat="server" id="form1">

    <asp:ScriptManager ID="ScriptManager1" runat="server" ScriptMode="Release"></asp:ScriptManager>

    <wl:app channel-url="http://labs.asteria.com.br/wlm/Channel.html" 
        callback-url="http://labs.asteria.com.br/wlm/Callback.aspx?wl_session_id=<%= Session.SessionID %>"
        client-id="0000000044052209" 
        scope="WL_Profiles.View" 
        onload="{{appLoaded}}">
    </wl:app>
    <wl:signin 
        id="signInControl" 
        signedintext="Signed in. Click to sign out." 
        signedouttext="Click to sign in."
        onsignin="{{signInCallback}}" />
    </form>
</body>
</html>

por Defecto.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        ClientScript.RegisterClientScriptInclude(this.GetType(), "live", "http://js.live.net/4.0/loader.js");
    }
}

Web.config

<?xml version="1.0"?>
<configuration>
<appSettings>
    <add key="wl_wrap_client_secret" value="[YOUR SECRET KEY]"/>
    <add key="wl_wrap_client_id" value="0000000044052209"/>
    <add key="wl_wrap_client_callback" value="http://labs.asteria.com.br/wlm/Callback.aspx"/>
</appSettings>

<connectionStrings/>
<system.web>
    <customErrors mode="Off"/>
    <compilation debug="true" targetFramework="4.0"></compilation>
    <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
</system.web>
</configuration>

Para verlo correr, puedes acceder a http://labs.asteria.com.br/wlm . Parece que la URL de Consentimiento (https://consent.live.com/AccessToken.aspx) no responde en este momento.

 3
Author: Tuco,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-06-02 19:22:13