SharePoint 2010:此页面的安全验证无效 [英] SharePoint 2010: The security validation for this page is invalid
问题描述
这是我用于检索项目的 Javascript 代码,它是一个 SharePoint 2010 (SP) 列表.
here's my Javascript code to retrieve items is a SharePoint 2010 (SP) list.
var clientContextPath = "/path/site1";
var clientContext = new SP.ClientContext(clientContextPath);
var oList = clientContext.get_web().get_lists().getByTitle(list);
var camlQuery = new SP.CamlQuery();
...
但是,如果我想从其他站点检索,即
However, if I want to retrieve from other site i.e.
var clientContextPath = "/path/site2";
然后相同的代码生成异常此页面的安全验证无效".这是在同一个域内,所以与XSS无关.
then same code generates exception " The security validation for this page is invalid". This is within the same Domain, so it's not something to do with XSS.
有趣的是,当我使用另一个站点时,相同的代码也能正常工作
Interestingly, same code works fine when I use another Site
var clientContextPath = "/path/site3";
请帮忙.谢谢.
推荐答案
我刚刚尝试过这个解决方案,我确信它不会奏效,但是……它确实奏效了!基本上,它是一个从 SharePoint 收集新令牌的 Ajax 请求.
I've just tried this solution, and I was sure it was not going to work but...it did! Basically it's an Ajax request to gather the new token from SharePoint.
$.ajax({
url: projecturl + "/_api/contextinfo",
method: "POST",
headers: { "Accept": "application/json; odata=verbose"},
success: function (data) {
$('#__REQUESTDIGEST').val(data.d.GetContextWebInformation.FormDigestValue);
EnsureScriptFunc('sharing.js', 'DisplaySharingDialog', function () { DisplaySharingDialog(projecturl) });
},
error: function (data, errorCode, errorMessage) {
alert(errorMessage)
}
});
这篇关于SharePoint 2010:此页面的安全验证无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!