Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 163557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T11:35:18+00:00 2026-05-11T11:35:18+00:00

I asked this question in the DataDynamics forum earlier today. I thought that maybe

  • 0

I asked this question in the DataDynamics forum earlier today. I thought that maybe I’d get some sort of response here at SO.

I am trying to get the WebViewer up and running in my ASP.NET MVC application. I am attempting to render the webviewer in the controller (webViewer.RenderControl(htmlTextWriter) and then put the results into ViewData and display the report in my view. I dont’ even know if this is the correct way to go about this. Any help would be greatly appreciated.

Controller code:

    public ActionResult Display()     {          CurrentReport = new DetailedReport { ReportData = new DetailedData() { Repository = _repository } };          var webViewer = new WebViewer();         CurrentReport.Run();         webViewer.ID = 'WebViewer1';         webViewer.Visible = true;         webViewer.ViewerType = ViewerType.HtmlViewer;         webViewer.Width = Unit.Percentage(100);         webViewer.Report = CurrentReport;           var stringWriter = new StringWriter();         var htmlTextWriter = new HtmlTextWriter(stringWriter);         webViewer.RenderBeginTag(htmlTextWriter);         webViewer.RenderControl(htmlTextWriter);         webViewer.RenderEndTag(htmlTextWriter);          ViewData['WebViewer'] = stringWriter.ToString();          return View();     } 

Display.aspx code:

<%@ Page Language='C#' MasterPageFile='~/Views/Shared/Admin.Master' Inherits='System.Web.Mvc.ViewPage' %> <%@ Register assembly='ActiveReports.Web, Version=5.2.1013.2, Culture=neutral, PublicKeyToken=cc4967777c49a3ff' namespace='DataDynamics.ActiveReports.Web' tagprefix='ActiveReportsWeb' %> <%@ Import Namespace='xxxx.Core'%>  <asp:Content ID='Content1' ContentPlaceHolderID='ClientAdminContent' runat='server'>     <%=ViewData['WebViewer'] %> </asp:Content> 

Error:

Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 60: var htmlTextWriter = new HtmlTextWriter(stringWriter); Line 61: webViewer.RenderBeginTag(htmlTextWriter); Line 62: webViewer.RenderControl(htmlTextWriter); Line 63: webViewer.RenderEndTag(htmlTextWriter); Line 64:

Source File: C:\Projects\xxxx\xxxx\app\xxxx.Web.Controllers\ReportsController.cs Line: 62

****Update:****

Based on the answer by scott (thank you) my controller now looks like this:

    public ActionResult Display()     {         ViewData['Report'] = new DetailedReport { ReportData = new DetailedReport { ReportData = new DetailedData() { Repository = _repository } };         return View();     } 

And my view looks like this: (I have no code behind files for my views).

<%     var report = (ActiveReport3) ViewData['Report'];     report.Run();     WebViewer1.Report = report; %> <ActiveReportsWeb:WebViewer ID='WebViewer1' runat='server' Height='100%' Width='100%' ViewerType='AcrobatReader' /> 

I watch it go through debugger, and it seems to correctly step through the Details section, putting values into my fields. But after all is done, I get the message ‘No Report Specified.’ I’m hoping that I really don’t have to use a codebehind file on my view because I’m not using them anywhere else. I have also debugged to verify that report.Document.Pages.Count > 0. I have put the code block both above and below the WebViewer control (don’t think that really matters). Any additional thoughts?

****Update #2:****

I ended up using the answer found here: Alternative to using the OnLoad event in an ASP.Net MVC View? in combination with scott’s excellent answer below. It was a timing thing with generating and binding the report to the control. So my View looks like this in the end… (where Model.Report is an ActiveReport3)

<script runat='server'>     private void Page_Load(object sender, EventArgs e)     {         var report = Model.Report;         report.Run();         WebViewer1.Report = report;     } </script>  <asp:Content ID='Content1' ContentPlaceHolderID='ClientAdminContent' runat='server'>     <ActiveReportsWeb:WebViewer ID='WebViewer1' runat='server' Height='100%' Width='100%' ViewerType='AcrobatReader' /> </asp:Content> 

Thanks for everyone’s help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T11:35:18+00:00Added an answer on May 11, 2026 at 11:35 am

    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

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.