Crystal Reports images do not load in ASP.NET MVC

I am using Crystal Reports in Webform inside an MVC application. However, images in reports are not displayed on both ASP.NET Development Server and IIS 7 (on Win7x64).

I know from a number of other issues, such as how the CrystalImageHandler HTTP handler is responsible for rendering the image, but I tried all the usual solutions to no avail.

I still have

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

Any ideas as to why the images are still 404?

+1
source share
4 answers

I had a similar problem. It helps me.

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

I tried many ways that you can apparently make work. Nothing. So I finally decided to trick:

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, corresponding to the expected Crystal (./CrystalImageHandler.aspx), and used this controller to call the handler during the execution of the action. Not beautiful, but functional.

+1
source

Have you tried adding it to system.webServer/handlers? This should fix this on IIS7, but it is strange that it does not work on the development server without this.

0
source

Add this to the RouteConfig.cs file

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

Note "Reports" is the name of the folder containing the aspx file for viewing reports, change this name of the folder to suit your application

0
source

All Articles