14 January 2009

Report Viewer Toolbar does not render properly on IIS 7.0

I was recently working on a reporting web application that uses the Report Viewer ( ReportViewer ) control that ships with SQL Server Reporting Services (SSRS). The Report Viewer control was rendering perfectly when I was developing using Visual Studio 2008. The trouble started when I published the web application to an IIS 7.0 server. The Toolbar was completely broken and showed up something like this.

SSRStoolbar

<rsweb:ReportViewer AsyncRendering="false" ID="reportViewer" Width="100%" Height="100%" runat="server" SizeToReportContent="True" > </rsweb:ReportViewer>

Initially it looked like just the images where missing. But the toolbar was completely broken. The toolbar of the Report Viewer control relies on images and JavaScript that are generated dynamically. It uses a call to the Reserved.ReportViewerWebControl.axd to dynamically generate the images and the JavaScript. Something like

GET /Reserved.ReportViewerWebControl.axd?OpType=Resource&Version=9.0.30729.1&Name=Microsoft.Reporting.WebForms.Icons.NextPage.gif HTTP/1.1

GET /Reserved.ReportViewerWebControl.axd?OpType=Resource&Version=9.0.30729.1&Name=Microsoft.Reporting.WebForms.Icons.LastPage.gif HTTP/1.1

When you use the Report Viewer Control Visual Studio edits your web.config to map a Http Handler to respond to these requests.

<system.web>
  <httpHandlers>
  <add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" validate="false"/>
  </httpHandlers>
</system.web>

The above entry tells ASP.NET that whenever a call is made to ReportViewerWebControl.axd use the Microsoft.Reporting.WebForms.HttpHandler assembly to execute it.

This mapping is very important because if you remove it the web server will return a 404 “File Not Found” error code because the ReportViewerWebControl.axd does not exist physically on the server.

Strangely when I checked the IIS 7.0 logs for the broken scenario I found that all requests for ReportViewerWebControl.axd had failed with a 404.

With IIS 7.0 there was an architectural change. There were changes to the web.config structure as well. The <httpHandlers> section that was under the <system.web> has now moved to <handlers> under <system.webServer>

Visual Studio had edited the web.config based on the IIS 6.0 model and had made an entry for the Http Handler under the <httpHandler> section. With IIS 7.0 this section is no longer read. So we need to make the proper entries for the Http Handler that handles the calls to ReportViewerWebControl.axd

<system.webServer>
    <handlers>
    <add name="ReportViewerWebControl" path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
    </handlers>
</system.webServer>

IIS 7.0 will now understand that whenever a call is made to ReportViewerWebControl.axd it needs to route it to the Http Handler Microsoft.Reporting.WebForms.HttpHandler


Bookmark and Share

Filed under: , ,
 

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# Mark Sowul said:

I miss the days when MS would bend over backwards for backwards compatibility - much less not making stupid breaking naming changes like this.  

14 January 09 at 11:32 PM
# Andrei said:

Create empty file in notepad

and save it under the name

Reserved.ReportViewerWebControl.axd

into folder containing Web.config.

22 January 09 at 12:25 PM
# Mike said:

Your blog cuts off a large portion of the code can you please post an entry with the full code for the handlers?

29 January 09 at 1:25 PM
# vijaysk said:

Mike I have added scroll bars around the code block. Hope it helps.

29 January 09 at 1:49 PM
# Mike said:

Thanks.  I tried to drop that into my code but no fix.  I know it applied to IIS 7.0 & I am running IIS 5.1 on XPSP2 with VS 2K8 and I am still getting the same thing.  Thanks for the scroll bars guess I will be back to the drawing board till I find a fix... If you have any ideas as to why I am getting the same error but on a different platform please feel free to shoot me a message trigeek512 at gmail dot com! Thanks & keep up the good work.

29 January 09 at 3:01 PM
# Useful IIS/ASP.NET Information provided by Microsoft Support Teams said:

I was recently working on a reporting web application that uses the Report Viewer ( ReportViewer ) control

10 February 09 at 4:55 PM
# Emil said:

Thank very much. reslove my problem.

26 February 09 at 9:32 PM
# Doni said:

Thank you.  This solved my problem.

31 March 09 at 11:28 AM
# Luis said:

Thank you. Solved my problem :)

21 April 09 at 2:53 PM
# Dennis said:

I could reach through my monitor and kiss you!  Thank you! Thank you!  I've been scratching my head all day on this one.  The picture of the broken tool bar at the top was golden.  I knew when I saw it that this page would be the exact fix I needed.

21 May 09 at 12:45 PM
# Sandra said:

Thank you thank you thank you!!!!!!!   I have been practically banging my head against the desk over this problem.  Your solution was EXACTLY what it took to fix it for me also!

12 June 09 at 1:28 PM
# Nav said:

Hi.. I was experiencing the same problem of the missing icons and report not rendering with ReportViewer 8.0 connecting to SSRS 2008 and IIS7. The above fix didn't solve the problem for me unfortunately. Does anyone think that the versions are incompatible...?

Thanks in advance!

15 October 09 at 8:31 AM
# Nav said:

Fixed!! It was the missing 'name' attribute and offending 'validate' attributes in my entry that was causing the issue.

So in conclusion, ReportViewer 8.0 does work with SSRS 2008 effortlessly!

Great post .. many thanks!

16 October 09 at 3:42 AM
# Nelson said:

What a beauty. It just worked adding the comments.

12 November 09 at 1:37 PM
# MeanYB said:

Thanks so much!  You saved me hours of troubleshooting!

03 December 09 at 6:49 AM

Leave a Comment

Comment Policy: No HTML allowed. URIs and line breaks are converted automatically. Your e–mail address will not show up on any public page.

(required) 
(optional)
(required) 

  
Enter Code Here: Required
Page view tracker