Niana
Niana

Reputation: 1047

Crystal report not showing images : CrytalImageHandler not found

I believe I have come across what I consider my most difficult task to do using crystal reports.

Problem

I am attempting to show to images on my report, one a varbinary stored in the database, and the second, a logo added from my desktop.The problem I am being faced with is, CrystalImageHandler not found and nothing I have tried works. And the following errors are thrown

http://localhost:1979/ASP/CrystalImageHandler.aspx?dynamicimage=cr_tmp_image_9b453c74-dbe2-4f03-832e-b1bd43e6ec43.png 404 (Not Found)

http://localhost:1979/ASP/CrystalImageHandler.aspx?dynamicimage=cr_tmp_image_0bf1fda9-3e87-446d-94a4-aaad9aa7e53d.png 404 (Not Found)

What I have tried

  1. I have attempted to ignore the routes. However, if I try to navigate to the image by removing the 'ASP' path where my aspx is, it still doesn't work. However, this is my RouteConfig.cs where the 'ASP' doesn't seem to be ignored

public class RouteConfig { public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.IgnoreRoute("{resource}.aspx/{*pathInfo}"); routes.IgnoreRoute("{*allaspx}", new { allaspx = @".*(CrystalImageHandler).*" }); routes.IgnoreRoute("ASP/{resource}.aspx/{*pathInfo}"); routes.IgnoreRoute("ASP/{resource}.aspx/{*pathInfo}");

    routes.MapRoute(
        name: "Default",
        url: "{controller}/{action}/{id}",
        defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
    );
}

}

  1. I have also attempted to add it to the handler tag in the web.config file. I have tried adding

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

to the main web.config however, on launching my application I get the error An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode. it then says I can ignore the error If you are certain that it is OK to ignore this error, it can be disabled by setting system.webServer/validation@validateIntegratedModeConfiguration to false. But setting that to false does not work.

  1. I place it in the second web.config file(the one in views folder., but that does not fix the issue of no picture being displayed.

I would greatly appreciate it if I am offered assistance or a bit of guidance to solve this issue. Cause it seems odd that something so simple could be this challenging.

Upvotes: 1

Views: 5040

Answers (4)

islam elgaidi
islam elgaidi

Reputation: 109

Add to RegisterRoutes

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

then fix CrystalImageHandler in Web.config

check web.config under <system.web> contains

(replace with crystal version)

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

and under <system.webServer> contains

 <handlers>
    <add name="CrystalImageHandler.aspx_GET" verb="GET" path="CrystalImageHandler*" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=13.0.3500.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" preCondition="integratedMode" />
  </handlers>

Replace All

path="CrystalImageHandler.aspx"

with

path="CrystalImageHandler*"

Upvotes: 1

Imamul Karim Tonmoy
Imamul Karim Tonmoy

Reputation: 584

After add necessary change in web.config. if still not work then you can try this For ASP.NET MVC Project in route config add followoing line

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

you may need to change the path according to aspx page location

Upvotes: 0

Mark Vance
Mark Vance

Reputation: 166

I faced a similar issue. I found success in altering the path within the code shown below from Web.config. I replaced CrystalImageHandler.aspx with CrystalImageHandler*. This seems to have resolved my issue. I don't really understand why to be honest. I came someone's post online who suggested that he could'nt find the CrsytalImageHandler.aspx page and decided to point only to CrystalImageHandler. I thought this might be worth a try for some.

I was using VS2015, .Net 4.5, C#

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

    <handlers>
          <add name="CrystalImageHandler.aspx_GET" verb="GET" path="CrystalImageHandler*" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" preCondition="integratedMode"/>
        </handlers>

Hope this helps,

Mark

Upvotes: 4

mmushtaq
mmushtaq

Reputation: 3520

I also faced this issue regarding loading images on crystal report in mvc but able to solve this issue by following these steps.

Possible Solutions:

The first thing to check is whether the Crystal Reports Image Handler has been included. This handler configuration doesn't seem to be added to the web.config by default, so open it up & look at the <httpHandlers> element. You need the following there:

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

Also, check the <handlers> element in the <system.webServer> parent node, as the handler needs to be added there as well:

<add name="CrystalImageHandler.aspx_GET" verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" preCondition="integratedMode"/>

Issue in ASP.NET MVC

If you are using Crystal Reports in ASP.NET MVC, the images may still fail to load. This is because the ASP.NET MVC routing engine is trying to map the resource request for the Image Handler to a controller action & since it can't, returns a 404 status.

To resolve this tell ASP.NET MVC routing engine to ignore requests for this resource. To do so, open up your routing configuration code (RouteConfig.cs).

There should already be an ignore for .axd resources. Add the following ignore rule:

routes.IgnoreRoute("{*allaspx}", new { allaspx = @".*(CrystalImageHandler).*" });

Source

Upvotes: 3

Related Questions