Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Crystal Reports Images and ASP.Net MVC

I am having trouble with Crystal Reports when using charts and images which use CrystalImageHandler.aspx. The image cannot display and I suspect this is due to a problem with MVC routing.

The path image path is similar to this:

src="/CrystalImageHandler.aspx?dynamicimage=cr_tmp_image_a8301f51-26de-4869-be9f-c3c9ad9cc85e.png"

With the URL similar to this:

localhost:01234/ViewCrystalReports.aspx?id=50

The image cannot be found prumably because it's looking in a non-existant directory. How can I change the path CrystalImageHandler.aspx is located at? I think if I were to reference from the root the problem would be solved but anything I change in Web.Config fails to work.

I should mention this is on a conventional aspx page, not a view etc

like image 262
Damien Avatar asked Jan 05 '10 12:01

Damien


2 Answers

I solve this problem editing Web.Config file

Insert the following line:

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

*take care with write your number version (Version=xx.x.xxxx.x)

like image 51
cmujica Avatar answered Nov 17 '22 11:11

cmujica


Figured it out. The routing was interfering with the CrystalImageHandler.aspx link that was being generated. Global.aspx has the following line to tell the routing engine to ignore resource files:

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

but this isn't a conventional resource file, it's an aspx file for some reason (anyone know why?)

adding this fixed it:

  routes.IgnoreRoute("{resource}.aspx/{*pathInfo}");
like image 2
Damien Avatar answered Nov 17 '22 12:11

Damien