我在MVC4 web應用程序中實現了RDLC報告(返回pdf文件字節)。無論用戶何時請求報告,Web應用程序都會停止對所有用戶的所有其他請求,除非此報告已呈現。有些報告大約100頁左右,所以Web服務器需要一段時間才能生成並呈現報告。在此期間,Web服務器無法處理其他請求。假設Web服務器正忙於渲染報告,並且在一個新選項卡中嘗試請求一些其他數據,除非該RDLC完成其操作,否則它將不會顯示。在開發機器中也是如此。請有人建議這是我的Web應用程序中的設計缺陷還是這是默認行爲?MVC4 RDLC停止所有其他請求
有沒有一種方法可以解決這個多線程或多任務?
這是報告渲染代碼,以防萬一,如果你想看到。但我只想讓其他人分享他們的經驗。
public byte[] RenderReport(PageType pageType, string ReportFormat, string ReportPath, ReportDataSource[] ReportDataModelList, out string mimeType, ReportParameter[] ReportParameters)
{
LocalReport lr = new LocalReport();
string path = Path.Combine(ReportPath);
lr.ReportPath = path;
foreach (ReportDataSource rds in ReportDataModelList)
{
lr.DataSources.Add(rds);
}
lr.EnableExternalImages = true;
lr.SetParameters(new ReportParameter("PrintedBy", PrintedBy));
foreach (ReportParameter rp in ReportParameters)
lr.SetParameters(rp);
string encoding;
string fileNameExtension;
string pageWidthHeight;
if (pageType == PageType.Portrait)
pageWidthHeight =
" <PageWidth>8.5in</PageWidth>" +
" <PageHeight>11in</PageHeight>";
else if (pageType == PageType.Landscape)
pageWidthHeight =
" <PageWidth>11in</PageWidth>" +
" <PageHeight>8.5in</PageHeight>";
else
pageWidthHeight =
" <PageWidth>8.5in</PageWidth>" +
" <PageHeight>11in</PageHeight>";
string deviceInfo =
"<DeviceInfo>" +
" <OutputFormat>" + ReportFormat + "</OutputFormat>" +
pageWidthHeight +
" <MarginTop>0.3in</MarginTop>" +
" <MarginLeft>0.3in</MarginLeft>" +
" <MarginRight>0.3in</MarginRight>" +
" <MarginBottom>0.3in</MarginBottom>" +
"</DeviceInfo>";
Warning[] warnings;
string[] streams;
byte[] renderedBytes;
renderedBytes = lr.Render(
ReportFormat,
deviceInfo,
out mimeType,
out encoding,
out fileNameExtension,
out streams,
out warnings);
return renderedBytes;
}
謝謝。
請張貼相關的代碼,並確切地顯示問題出在哪裏。 –
@learner我已經發布了代碼,但沒有什麼特別的代碼。我只想知道mvc rdlc的默認行爲。 –