我一直在寻找在ASP.Net MVC中进行报告的解决方案,我确实遇到了Rai Kaimal Rendering an RDLC directly to the Response stream in ASP.NET MVC的解决方案。一切正常,但localReport.Render()函数需要很长时间来呈现页面(2个非常简单的页面需要40秒 - 相同的报告在2秒内从winforms解决方案执行)。任何帮助,将不胜感激。如果没有办法加速报告,我很想知道其他开发人员如何在ASP.Net MVC解决方案中处理报告。
这是我的代码:
public ActionResult CustomerReport()
{
var localReport = new LocalReport
{
ReportPath = Server.MapPath("~/Reports/CustomerReport.rdlc")
};
var reportDataSource = new ReportDataSource("Customers", _repository.GetAll( ));
localReport.DataSources.Add(reportDataSource);
const string reportType = "PDF";
string mimeType;
string encoding;
string fileNameExtension;
//The DeviceInfo settings should be changed based on the reportType
//http://msdn2.microsoft.com/en-us/library/ms155397.aspx
const string deviceInfo = "<DeviceInfo>" +
" <OutputFormat>PDF</OutputFormat>" +
" <PageWidth>8.5in</PageWidth>" +
" <PageHeight>11in</PageHeight>" +
" <MarginTop>0.5in</MarginTop>" +
" <MarginLeft>1in</MarginLeft>" +
" <MarginRight>1in</MarginRight>" +
" <MarginBottom>0.5in</MarginBottom>" +
"</DeviceInfo>";
Warning[] warnings;
string[] streams;
//Render the report
byte[] renderedBytes = localReport.Render(
reportType,
deviceInfo,
out mimeType,
out encoding,
out fileNameExtension,
out streams,
out warnings);
return File(renderedBytes, mimeType);
}
答案 0 :(得分:0)
在<trust legacyCasModel="true" level="Full"/>
<system.web>
内的web.config
标记内放置# Adding a command to launch an application
if x[0] ['alternatives'] [0] ['transcript'] == 'run ' and Command_State is 'Started':
print("Running...")
Command_State = 'Run'
self.listening = True
为我做了。我在ASP.NET Webforms中。 More details here