C# ReportViewer控件-axd url
我在我的aspx中嵌入了C# ReportViewer控件-axd url,c#,webforms,reportviewer,C#,Webforms,Reportviewer,我在我的aspx中嵌入了Microsoft.Reporting.WebForms.ReportViewer控件。我的网站在mysite.com上运行。 例如,当尝试导出报告时,会打开一个带有地址的新黑色窗口 mysite.com/Reserved.ReportViewerWebControl.axd…工作正常。 但是我想通过我的代理传递那个axd。我的意思是,我想强制导出使用url myproxy.mysite.com/Reserved.ReportViewerWebControl.axd…将请
Microsoft.Reporting.WebForms.ReportViewer
控件。我的网站在mysite.com上运行。
例如,当尝试导出报告时,会打开一个带有地址的新黑色窗口
mysite.com/Reserved.ReportViewerWebControl.axd…
工作正常。
但是我想通过我的代理传递那个axd。我的意思是,我想强制导出使用url
myproxy.mysite.com/Reserved.ReportViewerWebControl.axd…
将请求重定向回mysite.com/Reserved.ReportViewerWebControl.axd…
我注意到,该链接是在js中构建的(包括在该axd中):
axd的url存储在
ExportUrlBase
中如何将其更改为我的代理服务器url?可以修改javascript中的ExportUrlBase
字段。报告本身存储在页面的某个占位符中,一旦找到,您可以在其上创建call _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上的inspect元素功能来检查实际下载链接时发现的,将有一个onclick方法,该方法利用页面上报告的ID。我看过的其他网站表明,如果您使用的是动态CRM,它可能会“reportViewer
”。最简单的方法是使用firebug或开发人员工具进行检查
不幸的是,这并不能完全解决您的问题,因为ExportUrlBase不存储整个URL,只存储与域相关的URL,即ExportUrlBase=“Reserved.ReportViewerWebControl.axd…”而不是“www.yoursite.com/Reserved.ReportViewer…”但是,一旦您可以更改它,您可以使用新配置在inetpub文件夹中创建一个目录,并通过该文件夹重定向链接以使用该配置
资料来源:
您可以尝试替换ExportReports()函数的行为:
Microsoft.Reporting.WebFormsClient._InternalReportViewer.prototype.ExportReport =
function(){ return "/proxypath" + this.ExportUrlBase }
window.open(
$find('ReportViewerControl').exportReport() + encodeURIComponent('CSV'),
"_blank"
);
Microsoft.Reporting.WebFormsClient._InternalReportViewer.prototype.ExportReport =
function(){ return "/proxypath" + this.ExportUrlBase }
window.open(
$find('ReportViewerControl').exportReport() + encodeURIComponent('CSV'),
"_blank"
);