ReportViewer renders invalid HTML

M Noreen 6 Reputation points
2020-12-08T15:03:05.613+00:00

In VS 2017, I set up an empty website and added the nuget package for the report viewer:

Install-Package Microsoft.ReportingServices.ReportViewerControl.WebForms

This installed v150.1427.0.

I added an aspx page with the report viewer control configured to use our ReportServer and a report. When I render that page in Firefox or Chrome, it displays broken image icons. Using devtools, I can select one of the broken images and look at its markup. The image tag is invalid HTML. It appears to be messing up where to put the blank.gif property and ALT attribute

<img 
src="/Reserved.ReportViewerWebControl.axd?ReportSession=rcy092c8e408e3.... blah.... blah...ResourceStreamID=Blank.gif ALT="  
blank="" 
image"="">
SQL Server Reporting Services
SQL Server Reporting Services
A SQL Server technology that supports the creation, management, and delivery of both traditional, paper-oriented reports and interactive, web-based reports.
3,063 questions
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. ZoeHui-MSFT 41,491 Reputation points
    2020-12-09T02:04:47.753+00:00

    Hi @M Noreen ,

    Thanks for @Alan Waiss raising a potential workaround which you also found here.

     protected override void Render( HtmlTextWriter writer )  
     {  
         if( Page.IsPostBack )  
         {  
             writer = new HtmlTextWriter_Fix( writer.InnerWriter );  
         }  
         base.Render( writer );  
     }  
     class HtmlTextWriter_Fix : HtmlTextWriter  
     {  
         public HtmlTextWriter_Fix( TextWriter writer ) : base( writer )  
         {  
         }  
         public override void Write( string s )  
         {  
             if( s.Contains( "ResourceStreamID=Blank.gif ALT=\"Blank image" ) )  
                 s = s.Replace( "ResourceStreamID=Blank.gif ALT=\"Blank image", "ResourceStreamID=Blank.gif\" alt=\"No content" );//[awaiss] The length has to match or the resulting content won't be parsed correctly (not sure why)  
             base.Write( s );  
         }  
     }  
    

    You may also raise the issue to Microsoft Feedback, the product team may help to do troubleshooting.

    Your feedback is valuable for us to improve our products and increase the level of service provided.

    https://feedback.azure.com/forums/908035-sql-server

    Regards,
    Zoe


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    What can I do if my transaction log is full?--- Hot issues November

    How to convert Profiler trace into a SQL Server table -- Hot issues November

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.