Javascript error when using Messenger Connect client-side library in ASP.NET

Hey, I tried some combinations here, and the one that worked was:

1) Set the ScriptMode property of the ScriptManager to Release;

2) Load the MSN library in the CodeBehind Page_Load event, using the ClientScript class:

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

Firebug isn’t showing any error anymore, and in my case, the authentication window is opening as desired.

Hope it helps!

EDIT

As told before, here follows the whole code I use to avoid this issue:

Default.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>

Default.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>

To see it running, you can access http://labs.asteria.com.br/wlm. It seems that the Consent URL (https://consent.live.com/AccessToken.aspx) is not responding at this time.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)