【发布时间】:2016-06-11 00:13:16
【问题描述】:
我正在尝试在我的 Angular 应用程序中实现一个 ssrs 报告。这是一些代码: 模板:
<div panel-charts style="width:100%:height:100%"
</div>
指令:
a.directive('panelCharts', function () {
return {
link: function (scope, elem, attrs) {
$(elem).load('http://localhost/Reportserver?/casechart&Title=abc');
}
}
});
我的应用程序根是 localhost:7063。
我得到以下信息: XMLHttpRequest 无法加载 http://localhost/Reportserver?/casechart&Title=abc。请求的资源上不存在“Access-Control-Allow-Origin”标头。因此,Origin 'http://localhost:7063' 不允许访问。响应的 HTTP 状态代码为 401。
我了解我的问题在于 CORS。我已将此添加到我的 web.config:
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
这没有帮助。但是我有一个按钮,当我点击它时会触发以下内容:
<button type="button" style="width:auto;" ng-click="runReport()">
Test
</button>
这在控制器中:
$scope.runReport = function () {
var win = window.open('http://localhost/Reportserver?/casechart&Title=abc', '_blank');
}
然后就可以了。
知道如何在不点击按钮的情况下使其工作吗?
谢谢
编辑 1。 要求:
Request URL:http://localhost/Reportserver?/casechart&Title=abc
Request Method:GET
Status Code:401 Unauthorized
Remote Address:10.229.232.73:80
请求头:
Accept:text/html, */*; q=0.01
Accept-Encoding:gzip, deflate, sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Host:localhost
Origin:http://localhost:7063
Referer:http://localhost:7063/Main.aspx
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.109 Safari/537.36
【问题讨论】:
标签: jquery angularjs reporting-services cors ssrs-2012