Crystal Reports Images and ASP.Net MVC

后端 未结 5 581
北海茫月
北海茫月 2021-01-06 03:09

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 wit

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-06 03:37

    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);
    
        }
    }
    

    This controller will invoke the handler. Just add a route to this as CrystalImageHandler.aspx, it can also be used with any sub path you'd like (in this case /reports). Something I could NEVER get the handler to do via configuration.

提交回复
热议问题