0

I'm trying to use SSRS reporting with an Asp.net MVC website with local reports.

I tried everything that is mentioned in this post, but I keep getting a hidden div with the following message instead:

The Report Viewer Web Control HTTP Handler has not been registered in the application's web.config file. Add to the system.web/httpHandlers section of the web.config file, or add to the system.webServer/handlers section for Internet Information Services 7 or later.

The handlers are correctly added to the web config and reports will work if I navigate to the aspx page directly (by , but since view engine is not involved I cannot use any of razor helpers, this problem only occurs when I'm using routing.

I have RouteExistingFiles = false and ignored the following routes:

{resource}.axd/{*pathInfo};
{resource}.aspx/{*pathInfo};
{resource}.ascx/{*pathInfo};

and disabled the BlockViewHandler by removing it from the webconfig.

I'm using Microsoft.ReportViewer for visual studio 2012 (ver 11.0.0.0)

Edit There is this post from Scot Hanselman about using razor views with ASPX master pages, I'm doing the exact reverse, using aspx user control with Razor layout, but this Microsoft report viewer does not work with this approach.

Community
  • 1
  • 1
mohas
  • 1,911
  • 1
  • 16
  • 20

1 Answers1

1

Because of your comments, I've found the reason because it's not working.

I have a User control that uses the report viewer, and a aspx page that uses that user control to show the reports. if I navigate directly to the report like: myhost/Views/Shared/ReportViewer.aspx it works, if I use routing like: myhost/report/myreport it wont work

When you navigate directly to the page, it's rendered by the "traditional" web forms infrasctructure, so all the elements needed by the report viewer (view state, script manager and son on) are available, and the report viewer works fine.

When you navigate using routing, form the comments:

yes creating a route that makes the reportviewer to be handled by an MVC controller which returns a razor view that renders report user control using Html.RenderPartial("ReportControl")

In this case, you're rendering a traditional web form as if it was a razor page. When you do this, all the infrastructure needed by the report viewer control is missing (particularly the view state), and thus it doesn't work.

So, you need to show the report viewer page as a traditional web form. You can open it in a new window/tab by using javascript. If you still want to integrate it in an existing MVC page, the only solution is to use an <iframe> and render the report inside it.

Another solution to integrate it directly in an MVC page would be to render the report using the Reporting Services web service, and sending the output to the browser (for example as a .jpg image or a PDF doc). But, whichever format you choose, it will lack the report viewer interactitvity.

JotaBe
  • 38,030
  • 8
  • 98
  • 117
  • I mentioned that reports work when I'm not using routing (which means navigating directly to the report viewer page), so obviously web config does not contain any issues. Whatever the issue is, it must be with the report viewer and asp.net mvc's statelessness. – mohas Jan 28 '14 at 07:01
  • Can you explain in more detail how are you trying the report: is there a report viewer in a .aspx page? How do you access it when it works, and when it fails? You're telling that if you navigate to the .aspx page directly it works. What do you don when you don't navigate to that page directly? If you give me that info, I'll try to help you. I'm afraid you're doing some kind of strange integration of a web forms user control inside an MVC page... o r perhaps you're creating a route that makes the reportviewer to be handled by an MVC controller, and it should run as a traditional web form page. – JotaBe Jan 28 '14 at 09:23
  • first I have a standard one area asp.net mvc folder structure, I have a User control that uses the report viewer, and a aspx page that uses that user control to show the reports. if I navigate directly to the report like: myhost/Views/Shared/ReportViewer.aspx it works, if I use routing like: myhost/report/myreport it wont work. – mohas Jan 28 '14 at 10:04
  • yes I'm `creating a route that makes the reportviewer to be handled by an MVC controller` which returns a razor view that renders report user control using Html.RenderPartial("ReportControl"). Yes I'm using a aspx user control inside a razor view, and it works except for the report viewer. – mohas Jan 28 '14 at 10:06
  • Updated my answer, according to your comments. – JotaBe Jan 28 '14 at 10:23