+5  A: 

We have investigated this internally and found the following solution. You can add the WebViewer to a View normally. There is no need for the complicated low-level interaction code in your example. Instead, just add the WebViewer to your aspx view normally. In our sample the WebViewer was added as follows:

<ActiveReportsWeb:WebViewer ID="WebViewer1" runat="server" Height="100%" Width="100%" ViewerType="AcrobatReader" />

That is enough to get the WebViewer working on the view.

In the controller we specified an ActiveReport as follows:

ViewData["Report"] = new SampleReport();

In the codebehind of the View we hook the report to the view:

WebViewer1.Report = ViewData["Report"] as ActiveReport3;

Then the tricky part begins. There are some IHttpHandlers used by ActiveReports when running under ASP.NET for some of the viewer types such as AcrobatReader / PDF. To ensure our handlers are working you must get ASP.NET MVC routing to allow them to process as normal. Luckily it is easy to do so. Just add the following line of code to the Global.asax.cs file:

routes.IgnoreRoute("{*allarcachitems}", new { allarcachitems = @".*\.ArCacheItem(/.*)?" });

That will ignore the route. Note that according to my reading there may be problems since ASP.NET routing seems to allow only a single "catch all" route like this. Therefore, if you have multiple of these IgnoreRoute commands and or you have any problems with a .axd file, you'll need to modify the constraints dictionary argument to accomidate the .axd as well as .ArCacheItem.

For more information see the following article: http://haacked.com/archive/2008/07/14/make-routing-ignore-requests-for-a-file-extension.aspx

You can download the full sample from our forums at http://www.datadynamics.com/forums/ShowPost.aspx?PostID=121907#121907

Scott Willeke
Data Dynamics / GrapeCity

scott
+1 for very useful info, thanks! the only detail that I needed cleared up was how to avoid using an actual codebehind file (see http://stackoverflow.com/questions/566902)
Aaron Palmer
Glad that answered your question. We should definitely not have added a code-behind, just added the event handler into the aspx. Anyway, that was pretty simple, glad you found a solution!
scott