嘿,我在这里尝试了一些组合,其中一个有效的是:
1) 将 ScriptManager 的 ScriptMode 属性设置为Release;
2) 在 CodeBehind Page_Load 事件中加载 MSN 库,使用 ClientScript 类:
protected void Page_Load(object sender, EventArgs e)
{
ClientScript.RegisterClientScriptInclude(this.GetType(), "live", "http://js.live.net/4.0/loader.js");
}
Firebug 不再显示任何错误,就我而言,身份验证窗口正在根据需要打开。
希望能帮助到你!
编辑
如前所述,下面是我用来避免这个问题的整个代码:
默认.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>
默认.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");
}
}
网页配置
<?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>
要查看它的运行情况,您可以访问http://labs.asteria.com.br/wlm。同意 URL (https://consent.live.com/AccessToken.aspx) 目前似乎没有响应。