嘿,我在这里尝试了一些组合,有效的是:
1)将scriptmanager的scriptmode属性设置为
释放
;
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");
}
}
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>
要看到它运行,您可以访问
http://labs.asteria.com.br/wlm
. 此时似乎同意URL(https://consent.live.com/accesstoken.aspx)没有响应。