on 06-23-2011 1:10 PM
Hello!
I'am using Crystal Reports for VS2010.
I host it on my own server.
I can not print report using my web application.
The reason is invalid url in script which is generated by Crystal Report Viewer .NET WebControl.
Client script which is generated by Crystal Report Viewer .NET WebControl:
bobj.crv.writeWidget({'cons':'bobj.crv.newViewer','args':{'id':'objCtrlCrystalReportViewer__UI','isDisplayModalBG':false,'visualStyle':{'className':'caBody','width':'1104px','height':'1202px'},'layoutType':'fitReport'},'children':[{'cons':'bobj.crv.newPrintUI','args':{'isActxPrinting':true,'codeBase':'../aspnet_client/system_web/4_0_30319/crystalreportviewers13/ActiveXControls/PrintControl.cab','url':'../MyWebApp/(S(43ldi5m4vt33atpiitubd1hd))/ToRunReport.aspx','paperOrientation':1,'paperSize':1,'paperWidth':0,'paperLength':0,'driverName':'Microsoft XPS Document Writer','useDefPrinter':false ...
The reason is in invalid path to original aspx page "../MyWebApp/(S(43ldi5m4vt33atpiitubd1hd))/ToRunReport.aspx"
It should be "../../MyWebApp/(S(43ldi5m4vt33atpiitubd1hd))/ToRunReport.aspx".
Are there any limitations for Crystal Reports .NET Runtime for VS 2010 working with ASP .NET web applications which saves session ID in URL?
Not that I know...
Can you share the code you are using?
- Ludek
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi!
Here is the sample of source code.
https://rapidshare.com/#!download|837l34|798603611|TestWebAppCrystal2010.rar|27
Try to host it with IIS 7.0 not with ASP .NET Development Server.
You will see a lot of errors and also main problem with ActiveX printing.
File version of Crystal .NET runtime file is 13.1.0.220.
Am I using old version?
Edited by: Basil2011 on Jul 21, 2011 4:45 PM
Hi!
I've tested with next combinations of values of "cookieless" attribute in "sessionstate" element:
1) cookieless="true" - does not work;
2) cookieless="UseCookies" - works OK;
3) cookieless="UseUri" - does not work.
Source code sample:
using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace TestWebAppCrystal2010
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
CrystalDecisions.CrystalReports.Engine.ReportDocument objDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
objDoc.Load(Server.MapPath(".
") + "TestReport.rpt");
DataTable dt = new DataTable();
dt.Columns.Add("Field01");
dt.TableName = "TestT1";
dt.Rows.Add(new object[] { 1 });
dt.Rows.Add(new object[] );
dt.Rows.Add(new object[] );
dt.Rows.Add(new object[] );
dt.Rows.Add(new object[] );
objDoc.SetDataSource(dt);
objDoc.SetDatabaseLogon("sa", "scala", "D307411", "TestDB");
CrystalReportViewer1.ReportSource = objDoc;
}
}
}
web.config:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="CrystalImageCleaner-AutoStart" value="true" />
<add key="CrystalImageCleaner-Sleep" value="60000" />
<add key="CrystalImageCleaner-Age" value="120000" />
</appSettings>
<connectionStrings>
</connectionStrings>
<system.web>
<sessionState cookieless="UseUri"></sessionState>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
<add assembly="CrystalDecisions.Shared, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
<add assembly="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
<add assembly="CrystalDecisions.ReportSource, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
<add assembly="CrystalDecisions.ReportAppServer.Controllers, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
<add assembly="CrystalDecisions.ReportAppServer.DataDefModel, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
<add assembly="CrystalDecisions.CrystalReports.Engine, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
<add assembly="CrystalDecisions.CrystalReports.Engine, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/><add assembly="CrystalDecisions.ReportSource, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/><add assembly="CrystalDecisions.Shared, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/><add assembly="CrystalDecisions.ReportAppServer.ClientDoc, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/></assemblies>
</compilation>
<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>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<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><validation validateIntegratedModeConfiguration="false"/></system.webServer>
</configuration>
See KB [1197229 - Using reverse proxies with the Crystal Reports for .NET WebForm Viewer control|http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_bi/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes%7B6163636573733d36393736354636443646363436353344333933393338323636393736354637333631373036453646373436353733354636453735364436323635373233443330333033303331333133393337333233323339%7D.do]. The KB was written for CR 12.x, but the idea is the same, just the version is different.
- Ludek
Hi,
For this : (post origin David)
https://answers.sap.com/questions/8463440/crystal-report-printing-error.html
<<<<The fix I found was to hack the Crystal Viewer javascript core library and modify the onPrint method to make an explicit check for the S(nnnn) session identifier.>>>
Does anyone know the code and the js file to modify to correct the cookieless = true and activex error problem in IE 11 ?
Thank you.
Dominique.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
Sorry for very long pause.
My application supports only Classic mode.
I see that the same happens with the latest SP5 for .NET Runtime.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello!
In my sample. I've tried to use classic application pool.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello!
Still is not answered o my last question.
When fix will be done in official .NET runtime package?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have encountered precisely this same error and have fixed it. I'm not sure this is the ideal fix, but it works.
The problem is due to a bug in the emitted Javascript for the Crystal Viewer Control. The control does not honor
or recognize cookieless environments in which the session is embedded in the URL of each request. The client Javascript does not
take into account the presence of the embedded session identifier, thus causing the subject reporting error.
The fix I found was to hack the Crystal Viewer javascript core library and modify the onPrint method to make an explicit check for the S(nnnn) session identifier.
I am not at my office computer at the moment, so I can't give you the exact details, but when I get there I will post the details. This solved the problem
for us, but it isn't exactly what I would consider a desireable fix. This took more than a few hours of tedious debugging to finally find the location of the problem.
-David
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
As I mentioned yesterday, I have encountered what I think is the same printing problem with the Crystal Viewer, and I have implemented a fix that I will share here.
Disclaimer
Before I post the fix, I will state that I make absolutely no promise, warranty, or guarantee of any kind that this fix will, in fact, remedy anyone else's particular problem, and if you undertake to implement this fix on your own systems, you do so entirely and completely at your own risk. This is a non-trivial fix to core javascript libraries buried deep within Crystal.
The Issue
The problem occurs when Active X printing is undertaken by a site employing cookieless sessions. The presence of the embedded session identifier in the runtime URL passed into the print code crashes the internal printing method of the viewer, causing the error message seen. The fix I implemented was to rewrite the URL passed to the onPrint method to check for the session ID, and rewrite the URL to omit it. Because the server maintains the session, the viewer doesn't care about it not being present, and printing succeeds.
Within the "allInOne.js" javascript files are the individual source elements of the Crystal client viewer that become the viewer within the Javascript runtime of the page hosting the CrystalReportViewer control. This file, in my case, is located here, with the drive letter indicating the drive hosting your inetpub folder for IIS.
For framework 4.0 sites -
c:\inetpub\wwwroot\aspnet_client\system_web\4_0_30319\crystalreportviewers12
For framework 2.0 sites -
c:\inetpub\wwwroot\aspnet_client\system_web\2_0_50727\crystalreportviewers12
The fix requires the introduction of additional code within the onPrint method, which is buried within the allInOne.js script file. Within the allInOne.js script file, located at line 483, column 396 per NotePad line numbering (with Word wrap disabled), there is a declaration of an anonymous Javascript function that follows ", _onPrint:"
(snipped code)...,_onPrint:function(){var printComponent=this._viewer._print;...}(snipped code).
This function is called when the onPrint method is invoked by the viewer. This is where the sessionID/URL rewrite code is added. I will caveat this code with the acknowledgment that the changes I made could certainly be written better/much more efficiently with regard to the string rebuild/reg exp (just a direct regular expression replacement), but this code worked and I opted not to go further).
Edited by: Don Williams on Sep 1, 2011 9:02 AM
Everyone, my apologies for the posting above. I rendered it with the editor-provided markup to highlight code properly, and the preview mode was correct, but when I see the message in the forum it is a single-line mess and I do not know how to fix it. As I said, it looks perfect in the preview pane.
Here is only the added code, hoping a simpler post won't mess up the rendering:
function()
{
var printComponent=this._viewer._print;
// added code for URL rewrite fix begins here - IMPLEMENT AT YOUR OWN RISK
var originalUrl = printComponent.url;
if (printComponent.isActxPrinting)
{
if (originalUrl.match(/\(S\(.*\)\)/))
{
var rebuildUrl = originalUrl.substring(0,originalUrl.indexOf("?"));
var escapeCount = 0;
while (rebuildUrl.substring(0,3)=="../")
{
rebuildUrl=rebuildUrl.substring(3);escapeCount++;
}
var slashCount=0;
var index =0;
while(index<rebuildUrl.length)
{
if (rebuildUrl.charAt(index)=="/")
{
slashCount++;
}
index++;
}
while(escapeCount < slashCount)
{
printComponent.url = "../" + printComponent.url;
escapeCount++;
}
}
}
// end added code for URL rewrite fix here - IMPLEMENT AT YOUR OWN RISK
if(printComponent)
{
if(printComponent.isActxPrinting)
{
bobj.crv.logger.info("UIAction Toolbar.Print ActiveX");
var pageState=bobj.crv.stateManager.getCompositeState();
var postBackData=this._ioHandler.getPostDataForPrinting(pageState,this._name);
this._viewer._print.show(true,postBackData);
}
else
{
bobj.crv.logger.info("UIAction Toolbar.Print PDF");
this._viewer._print.show(true);
}
}}
With all that said, I have modified the declaration of this method as follows:
function()
{
var printComponent=this._viewer._print;
// added code for URL rewrite fix begins here - IMPLEMENT AT YOUR OWN RISK
var originalUrl = printComponent.url;
if (printComponent.isActxPrinting)
{
if (originalUrl.match(/\(S\(.*\)\)/))
{
var rebuildUrl = originalUrl.substring(0,originalUrl.indexOf("?"));
var escapeCount = 0;
while (rebuildUrl.substring(0,3)=="../")
{
rebuildUrl=rebuildUrl.substring(3);escapeCount++;
}
var slashCount=0;
var index =0;
while(index<rebuildUrl.length)
{
if (rebuildUrl.charAt(index)=="/")
{
slashCount++;
}
index++;
}
while(escapeCount < slashCount)
{
printComponent.url = "../" + printComponent.url;
escapeCount++;
}
}
}
// end added code for URL rewrite fix here - IMPLEMENT AT YOUR OWN RISK
if(printComponent)
{
if(printComponent.isActxPrinting)
{
bobj.crv.logger.info("UIAction Toolbar.Print ActiveX");
var pageState=bobj.crv.stateManager.getCompositeState();
var postBackData=this._ioHandler.getPostDataForPrinting(pageState,this._name);
this._viewer._print.show(true,postBackData);
}
else
{
bobj.crv.logger.info("UIAction Toolbar.Print PDF");
this._viewer._print.show(true);
}
}}
Please note I have taken care to reformat the code so it is presentable here in this forum, so in that process I may have misaligned or omitted a brace or carriage return. The original code in the allInOne.js script is one continuous line that's next to impossible to read, which is one of the reasons this problem was so tough to debug. Needless to say, the fix required more than a few minutes of clicking through line-after-line of runtime code before the problem was identified. Obviously, the SAP folks need to fix the core code to anticipate cookieless sessions.
I saved the file, restarted IIS to ensure the change was loaded into any new report sessions, and my cookieless session printing problem disappeared without adverse impact to sites using conventional (cookied) sessions.
<h2>One last disclaimer....(sorry)</h2>
Again, I reiterate that this is a non-trivial change, because it affects core Crystal files. USE THIS FIX AT YOUR OWN RISK! It works for us, but I DO NOT GUARANTEE IT WILL WORK for anyone else.
Blessings to all,
David
Edited by: SoonerDave on Sep 1, 2011 5:44 PM Still trying to fix markup issues...sorry - it looks right in preview mode!!! ARRGGGH
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.