我有一个宏,可以检测访问者是否来自 Facebook,以及该访问者是否是该 facebook 页面上的管理员。
当我检测到管理员时,我运行以下代码以将访问者作为预定义管理员(Umbraco 后端用户)登录并重定向到实时编辑模式。这在 Chrome 中完美运行,但在 Internet Explorer 中不起作用。在 Internet Explorer 中,访问者在顶层(iframe 之外)被重定向到 Umbraco 登录页面,而不是登录。知道为什么吗?
var id = umbraco.BusinessLogic.User.getUserId("exampleadminuser"); // LoginName of an administrator
var u = umbraco.BusinessLogic.User.GetUser(id);
umbraco.BasePages.BasePage.doLogin(u);
// Check if the user should be redirected to live editing
if (u.DefaultToLiveEditing)
{
int startNode = u.StartNodeId;
// If the startnode is -1 (access to all content), we'll redirect to the top root node
if (startNode == -1)
{
if (umbraco.cms.businesslogic.web.Document.GetRootDocuments().Length > 0)
{
startNode = umbraco.cms.businesslogic.web.Document.GetRootDocuments()[0].Id;
}
else
{
throw new Exception("There's currently no content to edit. Please contact your system administrator");
}
}
string redir = String.Format("{0}/canvas.aspx?redir=/{1}.aspx", GlobalSettings.Path, startNode);
Response.Redirect(redir, true);
}