How to render Active Reports WebViewer in ASP.NET MVC

不想你离开。 提交于 2019-11-28 17:39:19

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

For anyone else having this issue and using IIS7 Make sure you add the Active reports handlers under the <handlers> section not <httpHandlers>.

<add name="RPX" verb="*" path="*.rpx" type="DataDynamics.ActiveReports.Web.Handlers.RpxHandler, ActiveReports.Web, Version=6.1.2814.0, Culture=neutral, PublicKeyToken=cc4967777c49a3ff"/>
            <add name="ActiveReport" verb="*" path="*.ActiveReport" type="DataDynamics.ActiveReports.Web.Handlers.CompiledReportHandler, ActiveReports.Web, Version=6.1.2814.0, Culture=neutral, PublicKeyToken=cc4967777c49a3ff"/>
            <add name="ArCacheItem" verb="*" path="*.ArCacheItem" type="DataDynamics.ActiveReports.Web.Handlers.WebCacheAccessHandler, ActiveReports.Web, Version=6.1.2814.0, Culture=neutral, PublicKeyToken=cc4967777c49a3ff"/>

I thought i had the IgnoreRoute setup improperly because I was getting 404 errors. However I was following the tutorial given by ActiveReports which has them in the IIS6 section instead of IIS7.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!