1

I'm using Crystal Reports in a Webform inside of an MVC application. Images in the reports are not being displayed, however, on both the ASP.NET Development Server and IIS 7 (on Win7x64).

I know from a number of other questions similar to this that the CrystalImageHandler HTTP Handler is responsible for rendering the image, but I've tried all of the usual solutions to no avail.

So far, I have

  1. Added the following to my appSettings (via http://www.mail-archive.com/bdotnet@groups.msn.com/msg26882.html)

    <add key="CrystalImageCleaner-AutoStart" value="true" />

    <add key="CrystalImageCleaner-Sleep" value="60000" />

    <add key="CrystalImageCleaner-Age" value="120000" />

  2. Added the following httpHandler to system.web/httpHandlers (via https://stackoverflow.com/questions/2253682/crystal-report-viewer-control-isnt-loading-the-images-inside-the-report)

    <add verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=12.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>

  3. Added the following to my Global.asax.cs (via Crystal Reports Images and ASP.Net MVC) routes.IgnoreRoute("{resource}.aspx/{*pathInfo}");

and routes.IgnoreRoute("CrystalImageHandler.aspx");

Any ideas as to why the images still 404?

Community
  • 1
  • 1
Ryan Shripat
  • 5,574
  • 6
  • 49
  • 77
  • @bummi, this question predates the 'original' by 2 years, how is this the duplicate? – Ryan Shripat Dec 21 '15 at 11:58
  • While I agree that the top-voted answer on the other question seems more thorough, I have to say that this question is better. It's very well researched, and shows the steps taken to attempt to arrive at a solution using other potential answers from the net. Please don't penalize me for the work I've taken to make this an SO-worthy question. – Ryan Shripat Dec 21 '15 at 12:15
  • Hi @bummi, this is clearly not the appropriate channel for this discussion, how can we continue it? – Ryan Shripat Dec 21 '15 at 12:20

4 Answers4

9

I had similar problem. This helped me.

routes.IgnoreRoute("{*allaspx}", new { allaspx = @".*(CrystalImageHandler).*" });
MorioBoncz
  • 920
  • 11
  • 22
1

I've tried the multitude of ways this can supposedly be made to work. None did. So I eventually settled on cheating:

public class CrystalImageHandlerController : Controller
{
    //
    // GET: /Reports/CrystalImageHandler.aspx

    public ActionResult Index()
    {
        return Content("");
    }

    protected override void OnActionExecuted(ActionExecutedContext filterContext)
    {

        var handler = new CrystalDecisions.Web.CrystalImageHandler();
        var app = (HttpApplication)filterContext.RequestContext.HttpContext.GetService(typeof(HttpApplication));
        if (app == null) return;

        handler.ProcessRequest(app.Context);

    }
}

I added a route to this controller matching what Crystal expects (./CrystalImageHandler.aspx) and used this controller to invoke the handler when the action is executed. Not pretty, but functional.

Nick Daniels
  • 922
  • 8
  • 13
0

Have you tried adding it to system.webServer/handlers? That should fix it on IIS7 but it is strange it doesn't work on the development server w/o that.

Cymen
  • 14,079
  • 4
  • 52
  • 72
  • I actually did add it to the IIS7 application web.config, to no avail.. I suspect that if it won't work on the dev. server it won't work on IIS. – Ryan Shripat May 28 '10 at 14:15
0

Add this in RouteConfig.cs file

routes.IgnoreRoute("Reports/{resource}.aspx/{*pathInfo}");

Note "Reports" is the folder name which contains the aspx file of report viewer change this folder name as per your application