ReportViewer showing broken images in Chrome
Asked Answered
M

6

10

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:

Screnshot

Any ideas on how to fix this?

Mantelpiece answered 21/11, 2012 at 17:23 Comment(2)
There's a seperate question for IE11 with the same root cause but totally different symptoms (IE11 just hangs).Renfrew
Possible duplicate of ReportViewer IE 11Danielladanielle
K
13

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;
}
Kindergarten answered 17/5, 2013 at 12:20 Comment(2)
This also fixes it for Windows 10 EdgeRetroflex
Where exactly do you add this? can you provide screen shots or path, and once inside the .css file where inside it do you append it to? Just a bit more context would be helpful for those, like myself, who aren't as familiar but require this fix to be applied.Jailhouse
D
3

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"));
    }
}
Danielladanielle answered 1/12, 2014 at 16:56 Comment(3)
You can avoid the performance hit of ToLower() by using IndexOf: req.Url.ToString().IndexOf("IterationId", StringComparison.OrdinalIgnoreCase) < 0 ToLower() creates a new string when it is called.Baecher
@D-Money, readability trumps micro optimizations - always. That said, you can do a case insensitive comparison without having to use index of by using String.Equals(a, b, StringComparison.OrdinalIgnoreCase)Danielladanielle
I agree about premature optimization. I thought it was worth a comment since this code runs on every request. Also, my code replaces the Contains code, not the Equals code.Baecher
Y
2

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.

Yttriferous answered 15/10, 2015 at 23:36 Comment(1)
Thank you. It helped me. the Simplest Solution that I found was to not use Line. I was using Line for the formatting purpose and it was mentioned in your comment and some other articles that i read that in older version of report viewer, it search for padding and calls a blank image. So I replaced Line with Textboxes with making the Top of the Textbox solid. This resolved my issue.Outgrow
E
0

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

Elaterid answered 23/5, 2017 at 19:45 Comment(0)
L
-1

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,

Larynx answered 16/2, 2015 at 16:26 Comment(1)
you need to put this code in Global.asax (in asp.net - VB) or in Global.asax.cs in C#Larynx
C
-1

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.

Countless answered 20/12, 2016 at 17:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.