CrystalImageHandler.aspx not found

后端 未结 4 1899
星月不相逢
星月不相逢 2021-01-05 06:32

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

相关标签:
4条回答
  • 2021-01-05 06:43

    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.

    0 讨论(0)
  • 2021-01-05 06:53

    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).*" });
    
    0 讨论(0)
  • 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

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