【发布时间】:2012-06-16 08:19:07
【问题描述】:
我正在使用带有 jsonp 端点的 ria 服务。当我在服务文件中调用我的方法时,它在 ie 和 firefox 中运行良好,但有时在 chrome 中运行,有时我得到“经过身份验证的服务不支持跨域 javascript 回调”。错误。即使我不使用经过身份验证的服务。
这是一段关于我所拥有的代码。
Jsonp 服务
[EnableClientAccess(RequiresSecureEndpoint = false)]
public class PPolJsonService : LinqToEntitiesDomainService<PPolAdvEntities>
{
public IQueryable<QuestionEntity> GetCompleteSurvey()
{
............
}
}
javascript 代码
function (data) {
var Params = {};
Params.type = 'GET';
Params.url = 'http://127.0.0.1:81/PPolSilverlight-Web-Services-PPolJsonService.svc/JSONP/GetCompleteSurvey;
Params.dataType = 'jsonp';
Params.data = { data:'somedata'};
Params.success = function (data) { };
Params.jsonpCallback = "ppolv2"
$.ajax(Params);
});
在 web.config 文件中我的设置是<authentication mode="Forms">
如果我设置了<authentication mode="None">,我就能够解决 chrome 的所有问题。但是应用程序的其余部分需要身份验证。所以这就是为什么我必须将它用作“mode=Forms”。如您所见,我的服务不使用身份验证,
为什么我会收到这个错误,有什么解决办法吗?
注意:
顺便说一下,我在 web.config 中还有其他设置,例如
<webHttpEndpoint>
<standardEndpoint crossDomainScriptAccessEnabled="true"
automaticFormatSelectionEnabled="true"/>
</webHttpEndpoint>
或者这些在clientaccesspolicy.xml中
<?xml version="1.0" encoding="utf-8"?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-request-headers="*">
<domain uri="http://*"/>
<domain uri="https://*" />
</allow-from>
<grant-to>
<resource path="/" include-subpaths="true"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>
但他们都没有帮助我。
提前致谢。
【问题讨论】:
标签: asp.net authentication cross-domain jsonp ria