Kle*_*vič 37 javascript asp.net asp.net-ajax sitefinity liveid
我在现有Sitefinity站点内实现新的Messenger Connect功能时遇到问题,无法使用Live ID启用客户端登录.
也就是说,当我使用以下代码实现客户端功能时:
<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>
Run Code Online (Sandbox Code Playgroud)
...我在Firebug中遇到三个错误,我无法正确识别:
Sys.ArgumentTypeException:"Sys._Application"类型的对象无法转换为"Sys.IDisposable"类型.参数名称:对象
(在ScriptResource.axd?d = ....第4993行)
Sys.Application._doInitialize不是一个函数
(在MicrosoftAjaxBase.js第1行)
Sys.InvalidOperationException:脚本"MicrosoftAjaxGlobalization.js"已被多次引用.如果显式引用Microsoft AJAX脚本,请将ScriptManager的MicrosoftAjaxMode属性设置为Explicit.
(在ScriptResource.axd?d = ....第984行)
仅当我loader.js从js.live.net 包含脚本时才会触发错误.
编辑:似乎错误不一定按该顺序触发.刷新页面似乎打乱这些错误和/或引入其他的,如Sys.ParameterCountException在ScriptResource.axd?...上线1842,例如.
嘿,我在这里尝试了一些组合,有效的组合是:
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");
}
Run Code Online (Sandbox Code Playgroud)
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>
Run Code Online (Sandbox Code Playgroud)
默认.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");
}
}
Run Code Online (Sandbox Code Playgroud)
网页配置
<?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>
Run Code Online (Sandbox Code Playgroud)
要查看它的运行情况,您可以访问http://labs.asteria.com.br/wlm。同意 URL (https://consent.live.com/AccessToken.aspx) 此时似乎没有响应。
| 归档时间: |
|
| 查看次数: |
1978 次 |
| 最近记录: |