Crystal Reports Images and ASP.Net MVC

后端 未结 5 539
北海茫月
北海茫月 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:22

    To view in local machine,you will add the following code in web config

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

    ...............................

    <appSettings>       
    <add key="CrystalImageCleaner-AutoStart" value="true" />
    <add key="CrystalImageCleaner-Sleep" value="60000" />
    <add key="CrystalImageCleaner-Age" value="120000" />    
    </appSettings>
    

    The following code is for displaying in server

    <system.webServer>      
    <handlers>                
        <add name="CrystalImageHandler.aspx_GET" verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" preCondition="integratedMode"/> 
    </handlers>
    </system.webServer>
    

    :) I will solve that problem in adding in web config

    0 讨论(0)
  • 2021-01-06 03:26

    It's because the routing was interfering with the CrystalImageHandler.aspx. So either in Global.asax or routeConfig file we can ignore route for .aspx extension files. You can ignore .aspx extension route by adding following line.

    routes.IgnoreRoute("{allaspx}", new {allaspx=@"..aspx(/.*)?"});

    0 讨论(0)
  • 2021-01-06 03:31

    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)

    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2021-01-06 03:39

    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}");
    
    0 讨论(0)
提交回复
热议问题