报表查看器控件 - axd 网址
本文关键字:axd 网址 控件 报表 | 更新日期: 2023-09-27 17:55:15
我已经在我的aspx中嵌入了Microsoft.Reporting.WebForms.ReportViewer
控件。我的网站适用于 mysite.com。当尝试exmple导出报告时,打开了带有地址的新黑色窗口 mysite.com/Reserved.ReportViewerWebControl.axd...
它工作正常。但。。我想通过我的代理传递该 axd。我的意思是,我想强制导出以使用 url myproxy.mysite.com/Reserved.ReportViewerWebControl.axd...
,这会将请求重定向回mysite.com/Reserved.ReportViewerWebControl.axd...
我注意到,该链接是在 js 中构建的(包含在该 axd 中):
ExportReport: function(format)
{
if (this.ExportUrlBase == null)
return false;
window.open(this.ExportUrlBase + encodeURIComponent(format), "_blank");
return true;
},
axd 的网址存储在 ExportUrlBase
中。如何将其更改为我的代理服务器网址?
可以在 javascript 中修改ExportUrlBase
字段。报告本身存储在页面上某处的占位符中,一旦找到,您可以在其上创建调用 _getInternalViewer() 函数以访问 ExportUrlBase。请看下面的代码:
function ModifyExportUrlBase()
{
var rv = null;
var r = null;
try
{
// get the report viewer
rv = this.$find("ctl31");
r = rv._getInternalViewer();
}
catch(err)
{
console.log(err)
setTimeout(ModifyExportFileName, 2000)
return;
}
if(r == null)
{
setTimeout(ModifyExportFileName, 2000);
return;
}
else{
r.ExportUrlBase = "/yourproxypath" + r.ExportUrlBase
}
}
ModifyExportUrlBase();
超时是必需的,因为报告是异步接收的,并且只有在报告完全加载后才有效。
ctl31
是使用 firebug 上的检查元素功能来检查实际下载链接时找到的,将有一个利用页面上报告的 ID 的 onclick 方法。我看过的其他网站表明,如果您使用动态CRM,它可能会"reportViewer
"。找出答案的最简单方法是使用Firebug或开发人员工具进行检查。
不幸的是,这不是您的问题的完全修复,因为ExportUrlBase不存储整个URL,只存储相对于域的URL,即ExportUrlBase = "Reserved.ReportViewerWebControl.axd..."不是"www.yoursite.com/Reserved.ReportViewer..."但是,一旦您可以更改此设置,您就可以使用新配置在 inetpub 文件夹中创建一个目录,并通过该文件夹重定向链接以使用该配置。
来源:
http://reportsyouneed.com/ssrs-adding-date-to-exported-filenames/
https://www.dforge.net/2012/11/11/how-to-specify-a-filename-for-your-exported-reports-in-microsoft-dynamics-crm-2011/
您可以尝试替换 ExportReports() 函数的行为:
Microsoft.Reporting.WebFormsClient._InternalReportViewer.prototype.ExportReport =
function(){ return "/proxypath" + this.ExportUrlBase }
window.open(
$find('ReportViewerControl').exportReport() + encodeURIComponent('CSV'),
"_blank"
);