问题
I'm using ReportViewer
10.0. In Google Chrome, the lines come with a broken image called blank.gif
. But IE and Firefox are working fine.
Here's an example with the images circled:
Any ideas on how to fix this?
回答1:
Just add the following CSS from SQL Reporting Services - Viewer broken in Non-IE Browsers:
body:nth-of-type(1) img[src*="Blank.gif"]{
display:none;
}
回答2:
The current solution will mask the issue, but won't address the underlying problem, which is that when browsers besides IE are composing the request for the gif (which SSRS just uses to replace padding), they don't know to include the IterationId
query string parameter.
As SQL Reporting Services Viewer broken in Non-IE Browsers points out, if you're using the ReportViewer, you can fix this in your application routing under Application_BeginRequest
like this:
protected void Application_BeginRequest(object sender, EventArgs e)
{
// Original fix credit to Stefan Mohr
// Bug fix for MS SSRS Blank.gif 500 server error missing parameter IterationId
// https://connect.microsoft.com/VisualStudio/feedback/details/556989/
HttpRequest req = HttpContext.Current.Request;
if (req.Url.PathAndQuery.StartsWith("/Reserved.ReportViewerWebControl.axd") &&
!req.Url.ToString().ToLower().Contains("iteration") &&
!String.IsNullOrEmpty(req.QueryString["ResourceStreamID"]) &&
req.QueryString["ResourceStreamID"].ToLower().Equals("blank.gif"))
{
Context.RewritePath(String.Concat(req.Url.PathAndQuery, "&IterationId=0"));
}
}
回答3:
Workaround: use rectangles/textboxes/tablix cells and only have one of their borders showing. Works on chrome. For the OP, he can add extra columns as spacers between the data columns and skip showing the border for those.
回答4:
I had the same error with Reportviewer version 10 so I update to version 14, it solve the problem and get some enhancements, compelte guide here
回答5:
In my case its response not working in test mode (Localhost), but I corrected and now it works , instead of putting " StartsWith " I put "Contains". It's the code:
Protected Sub Application_BeginRequest(sender As Object, e As EventArgs)
' Original fix credit to Stefan Mohr
' Bug fix for MS SSRS Blank.gif 500 server error missing parameter IterationId
' https://connect.microsoft.com/VisualStudio/feedback/details/556989/
Dim req As HttpRequest = HttpContext.Current.Request
If req.Url.PathAndQuery.Contains("/Reserved.ReportViewerWebControl.axd") AndAlso Not req.Url.ToString().ToLower().Contains("iteration") AndAlso Not [String].IsNullOrEmpty(req.QueryString("ResourceStreamID")) AndAlso req.QueryString("ResourceStreamID").ToLower().Equals("blank.gif") Then
Context.RewritePath([String].Concat(req.Url.PathAndQuery, "&IterationId=0"))
End If
End Sub
Hope you help,
回答6:
As the other answers, I solved this problem adding the following code to my Global.asax file:
void Application_BeginRequest(object sender, EventArgs e)
{
//The following code is a hack for stopping a broken image from magically appearing on SSRS reports in chrome
//where ever a line is used in the report.
Uri u = HttpContext.Current.Request.Url;
//If the request is from a Chrome browser
//AND a report is being generated
//AND there is no QSP entry named "IterationId"
if (HttpContext.Current.Request.Browser.Browser.ToLower().Contains("chrome") &&
u.AbsolutePath.ToLower().Contains("reserved.reportviewerwebcontrol.axd") &&
!u.Query.ToLower().Contains("iterationid"))
HttpContext.Current.RewritePath(u.PathAndQuery + "&IterationId=0");
}
But, maybe you had missed or don't have the Global.asax file, as happened to me. So select your solution and go to:
File > New > File > Web > C#/VB.Net > Global Application Class
Save it as Global.asax, paste the code and it will solve your problem.
来源:https://stackoverflow.com/questions/13498696/reportviewer-showing-broken-images-in-chrome