Reputation: 1339
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
Upvotes: 7
Views: 18406
Reputation: 21
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
Upvotes: 2
Reputation: 51
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>
Upvotes: 5
Reputation: 1034
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).*" });
Upvotes: 6
Reputation: 1326
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.
Upvotes: 13