问题
I have a report viewer control that show's a dashboard stye report. It has a few charts to give an overview, however when viewing in IE11 the report doesn't render at all and just shows up blank. The underlying stored procedure is being ran as well.
I did some testing and
- Charts show up in Firefox (Current)
- Charts show up in Chrome (Current)
- Charts show up in IE Compatibility Mode.
- If I use the PDF export feature on my web viewer it's able to convert the original byte stream to the correct PDF with the charts, which meant the report ran properly. The underlying stored procedure only ran once when attempting to display the report initially.
I'm not sure if this is a problem with how IE interacts with the webviewer control.
Update - With the magic of Fiddler, it looks like an error was being eaten and not shown when requesting a blank.gif, this seems to be a place holder for the result gif I believe. The IterationId is missing in the URL. The odd thing is that reviewing the Fiddler trace results for FireFox and Chrome the same error regarding IterationId missing from the URL appears however the charts still show. I'm assuming this is still the issue though.
Request header
GET /Reserved.ReportViewerWebControl.axd?ReportSession=....&Culture=1033
&CultureOverrides=True&UICulture=1033&UICultureOverrides=True
&ReportStack=1&ControlID=...
&OpType=ReportImage&ResourceStreamID=Blank.gif HTTP/1.1
Text Resonse
[HttpHandlerInputException: Missing URL parameter: IterationId]
Microsoft.Reporting.WebForms.HandlerOperation.GetAndEnsureParam(NameValueCollection urlQuery, String paramName) +104
Microsoft.Reporting.WebForms.ReportImageOperation.PerformOperation(NameValueCollection urlQuery, HttpResponse response) +102
Microsoft.Reporting.WebForms.HttpHandler.ProcessRequest(HttpContext context) +380
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +599
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +171
回答1:
The missing IterationId helped me find similar scenarios. It makes sense that the IterationId would fail in IE11 as in Chrome and Firefox since IE11 introduces itself as a Mozilla client. "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"
Per this article by Devin Steinke on SQL Reporting Services - Viewer broken in Non-IE Browsers
In my Global.asax code behind I append the IterationId parameter only on the request for the ReportViewerWebControl blank.gif. It works in IE11 now and still works in FireFox, Chrome and older versions of IE.
You won't see an exception from fiddler anymore, and the result text displays the retrieval of a GIF, "GIF89a" in my case.
VB.NET:
Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
Dim pathQuery = HttpContext.Current.Request.Url.PathAndQuery
Dim url = HttpContext.Current.Request.Url.ToString().ToLower()
If pathQuery.StartsWith("/Reserved.ReportViewerWebControl.axd") And Not url.Contains("iteration") Then
Dim resourceStreamId = HttpContext.Current.Request.QueryString("ResourceStreamId")
If IsNothing(resourceStreamId) Then Return
If resourceStreamId.ToString().Equals("blank.gif", StringComparison.InvariantCultureIgnoreCase) Then
Context.RewritePath(String.Concat(HttpContext.Current.Request.Url.PathAndQuery, "&IterationId=0"))
End If
End If
End Sub
C#:
void Application_BeginRequest(object sender, EventArgs e)
{
// Bug fix for MS SSRS Blank.gif 500 server error missing parameter IterationId
// https://connect.microsoft.com/VisualStudio/feedback/details/556989/
if (HttpContext.Current.Request.Url.PathAndQuery.StartsWith("/Reserved.ReportViewerWebControl.axd") &&
!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["ResourceStreamID"]) &&
HttpContext.Current.Request.QueryString["ResourceStreamID"].ToLower().Equals("blank.gif"))
{
Context.RewritePath(String.Concat(HttpContext.Current.Request.Url.PathAndQuery, "&IterationId=0"));
}
}
来源:https://stackoverflow.com/questions/28049691/ssrs-report-viewer-report-chart-fails-to-display-in-ie11