CrystalImageHandler.aspx not found
Asked Answered
R

4

7

I am using Crystal reports viewer on a normal ASP.NET aspx page in an MVC3 application. In a controller action I am simply redirecting to the aspx page and the report shows fine. But the problem is with dynamic images. I have found the simplest solution for this and this to pass the image path as a report parameter and set this parameter as image source. In Visual Studio preview this works fine but when executing I see this error on the page.

"NetworkError: 404 Not Found - server/ReportWebForms/CrystalImageHandler.aspx?dynamicimage=cr_tmp_image_4fbcb73a-e001-4365-84fc-164788dd1605.png"

So I assume, having no previous experience with crystal reports, that the problem is in CrystalImageHandler.aspx. I have these entries in the Web.config:

  <httpHandlers><add verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/></httpHandlers></system.web>
  <handlers><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"/></handlers></system.webServer>

Is this an MVC type of a problem? Can anyone help with this please?

THank you

Rhenium answered 6/7, 2012 at 7:38 Comment(2)
I gave up on Crystal reports for my solution. Too many problems with it and it was CRASHING my VS 2010 too often. I will now create html pages to display the reports on the page in the application and will use iTextSharp library, which I find very good, to create PDFs to download. This way I have control over every single line in the report creation process unlike BlackBox Crystal Reports. THIS COULD HELP SOMEONE DECIDE WHAT APPROACH TO TAKE WHEN IN THE SAME POSITION AS I WAS.Rhenium
Possible duplicate of Crystal Reports Images not loading in ASP.NET MVCMurmansk
S
13

I had the same problem, but fortunately I have some experience with Crystal Reports.

You just need to change the Web.config, because the "path" attribute is set to site root. It will work if you open the url in browser and remove the ReportWebForms from it.

Actually I've just added 2 more lines of configuration:

<system.web>
    <httpHandlers>
      <add verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" />
      <!-- Added -->
      <add verb="GET" path="Reports/CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" />
      <add verb="GET,HEAD" path="asset.axd" validate="false" type="Telerik.Web.Mvc.WebAssetHttpHandler, Telerik.Web.Mvc" />
    </httpHandlers>
</system.web>

<system.webServer>
    <handlers>
      <add name="MiniProfiler" path="mini-profiler-resources/*" verb="*" type="System.Web.Routing.UrlRoutingModule" resourceType="Unspecified" preCondition="integratedMode" />
      <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" />
      <!-- Added -->
      <add name="CrystalImageHandler.aspx_GETR" verb="GET" path="Reports/CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" preCondition="integratedMode" />
      <remove name="asset" />
      <add name="asset" preCondition="integratedMode" verb="GET,HEAD" path="asset.axd" type="Telerik.Web.Mvc.WebAssetHttpHandler, Telerik.Web.Mvc" />
    </handlers>
</system.webServer>

And finally you have to add an ignore rule the route for MVC application:

routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("{resource}.aspx/{*pathInfo}");
// Here is added new ignore rule
routes.IgnoreRoute("Reports/{resource}.aspx/{*pathInfo}");

In my case I have a folder named Reports where the .aspx file is placed. I guess you should change this to ReportWebForms in your case.

Stagey answered 4/11, 2013 at 13:46 Comment(2)
I gave up on the Crystal reports, as I said in the comment of the question, but I will accept this as an answer as it might help someone else.Rhenium
Always difficult to troubleshoot this simple issue! In my case just adding another ignoreRoute with the folder name was enough to solve this issue.Batholith
D
6

In my case I only had to ignore MVC's routing.To add onto @Hovhannes solution.You should add this rule to Routeconfig.cs

routes.IgnoreRoute("{*allaspx}", new { allaspx = @".*(CrystalImageHandler).*" });
Dianthe answered 27/7, 2015 at 17:26 Comment(1)
The accepted answer had worked for every previous deployment, until today. For some reason nothing displayed the images, because it was appending the CrystalImageHangdler.aspx to the current url (test.server/report.aspxCrystalImageHAndler.aspx). But adding this ignoreRoute was the only way around it.Batholith
C
5

Use this code as CrystalImageHandler.aspx:

<%@ Page Language="C#" AutoEventWireup="true" %>

<script runat="server" language="c#" >
    protected void Page_Load(object sender, EventArgs e)
    {
        CrystalDecisions.Web.CrystalImageHandler handler = new CrystalDecisions.Web.CrystalImageHandler();
        handler.ProcessRequest(this.Context);            
    }
</script>
Crawfish answered 1/10, 2018 at 20:5 Comment(2)
Added the page ("CrystalImageHandler.aspx") under the folder where report is created and added the above code in Page_Load, it shows the image.Sibby
Wow, i didn't think that was going to work. But it did! Thanks!!Band
O
2

Answers: Add this in RouteConfig.cs file

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

Note : "Reports" is the directory name which contains crystal reports viewing aspx page

enter image description here

Ottar answered 17/12, 2015 at 7:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.