I'm looking for a way to obtain the report URL from within an SSRS report that is defined locally in an ASP.NET web application. I've tried using the Globals!ReportServerUrl Built-in field, but its not giving me anything useful ( just shows as #ERROR when I place the value in a text box ). I guess this is to be expected since the report doesn't actually live on report server and is defined locally in the app. Any input would be much appreciated.
Thanks in advance.
As pointed out in the comments, RDLC is rendered "locally". This -confusingly- may be on a server, but will still not have a Report Server URL (which is the cause for the error).
In the report you have no obvious way to find any HttpContext items like the request URL, which you seem to be after.
Simplest solution is probably to create a report parameter #RequestUrl and pass something from the HttpRequest into it.
(There's also Custom Code, which you could try, but I doubt it has access to the request URL.)
Related
I have a browser-based InfoPath 2010 form. I'm getting an error opening the form in one environment. It works in at least three other environments. The error is:
The form template failed to load... Type: XmlException, Exception Message: For security reasons DTD is prohibited in this XML document. To enable DTD processing set the ProhibitDtd property on XmlReaderSettings to false and pass the settings into XmlReader.Create method.
I have seen this question posted around the Web, but the answers are vague and varied and are centered around products besides InfoPath. We also have other forms working in the environment where this form is failing, so it's something related to this particular form in this particular environment.
Problem solved. The error message was misleading, but turns out one of the data connections had a URL pointing to the wrong SharePoint farm. It was supposed to be pointing to the local form library. Cross platform calls tend not to work.
Basically make sure that the domain name in the connection file is matching the domain name where you're publishing your form.
For example, if your InfoPath form is located in:
https://extranet.MySiteName.com/The-Rest-Of-Your-Domain-Name
then make sure that all the domains (in this example extranet.MySiteName.com/)
in your data connection file match. The connection file line may look similar to this:
<udc:Query>
https://extranet.MySiteName.com/_vti_bin/My-WCF-Services/My-Data-ServiceName.svc/
</udc:Query>
I'm having some serious issues trying to get a Crystal Reports report printed from an ASP.Net page. Here is the current setup:
A Crystal Reports viewer is set up on a page. The report appears fine when viewing the report.
The report viewer PrintMode is set to ActiveX
I am setting the report data source from a session variable, as per SAP's recommendation (found in one of their knowledge base articles). The report data source is being set by a call to a WCF service. The data being passed into the report is fine. (Again, the report displays just fine, showing all content like it should).
The build target for the ASP.Net application and related services are x86.
Everything is using Crystal Reports version 13, and the ASP.Net web application is using .Net 4. It is being viewed in Internet Explorer 8.
I've tried checking the ActiveX settings on Internet Explorer 8, and none of them should be a problem (everything is either set to allow or prompt).
The error happens regardless of running it from the IDE or from a set up website on a separate server.
The settings for the application pool in IIS on the other server are set to allow 32 bit applications.
When I click on the Print icon on the report viewer, I get the following error message:
"An communication error occurred. Printing will be stopped."
This same error happens more than one machine. If I click OK on the error message the dialog underneath says "Please wait while the Crystal Reports Print Control is loaded.". If I wait, nothing happens. There is no prompt to install an ActiveX control, and nothing pops up allowing me to select a printer (of which I know several are installed).
I've tried doing the following things, none of which have worked:
Switch the report type to PDF. If I do this, and click the print button on the report viewer I get the following error:
Microsoft JScript runtime error: Object required."
It breaks on this line in particular:
bobj.crv.stateManager.setComponentState('MainContent_reportViewer_UI',eval('('+document.getElementById('_CRYSTALSTATEctl00$MainContent$reportViewer').value+')'));
There are several dynamic images in the report, but all of them are being displayed correctly when viewing the report. They are the only binary objects that I can think of that would be associated with this report. The error is happening in the dynamically created code for the page - not something that I have written.
I've tried manually installing the ActiveX control from the correct .cab file. This made no difference in any of the scenarios.
I've installed the latest Crystal Reports service pack (service pack 3). Again, this didn't change anything.
I've tried setting up a Virtual Directory for the CrystalReportViewers13 inside the Default Web Site, as recommended by some forum posts I came across. This also has had no effect.
Enabling ViewState on the page has no effect on whether printing works or not.
I've tried adding my own print button and a drop down list with a list of available printers. When I click my own custom print button and call PrintToPrinter(), I get the same error message as trying to print a PDF report:
"Microsoft JScript runtime error: Object required"
...and it breaks on the same line as when trying to print a PDF report when clicking the Print button.
I've been beating my head against this for at least a day now, and I'm fresh out of ideas. Anyone have any idea what might be causing this?
EDIT:
Well, here's what I did in order to get things to work. It ended up being a lot simpler of a fix than what I was thinking:
Stuff the entire ReportDocument into the session. Your page load should look something like this:
protected void Page_Load(object sender, EventArgs e)
{
if (Session["report"] != null)
{
reportViewer.ReportSource = Session["report"];
}
BuildReport();
}
Keep the ReportViewer as simple as possible - don't specify the report type (PDF or ActiveX). Setting it to anything seemed to result in problems. This is what it looks like in the page source:
... and that was it. I can't believe I spent about a day trying to get it to work when it ended up being so simple. Hopefully this post helps anyone else facing the same problem.
Its bad idea to store entire report in session if you are receiving lot of user requests.
While working with crystal reports you must reinitialize the report and its login and datasource, parameters etc in each request (post back or no postback does not matter ) before sending out the response. Crystal report does not maintain complete viewstate that is why it should reinitialized each time.
I think you are not reinitializing during postback requests hence the error.
Save yourself the headache and DISABLE activeX printing. It blows up your web server with temp files, only works with IE, and is limited to the number of reports you can print at the same time. Set the print mode to Pdf and be done with it. A lot of browsers can print pdfs directly.
crViewer.PrintMode = PrintMode.Pdf;
I know this question is old, but I thought I'd chime in just in case someone else has this problem.
I found this page had a number of options for problems that I think are very similar to yours. I was getting the titled 'bobj is undefined' error, but all it really comes down to is that IIS can't find a proper path to the JS files for Crystal.
For myself I ended up placing some folders in my aspnet_client directory in the root of my site (wwwroot) and ensuring that NETWORK_SERVICE had access to the aspnet_client folder. I had to do the same with the 'crystalreportviewers' folder from my x86 SAP folder under
'C:\Program Files (x86)\SAP BusinessObjects\Crystal Reports 20XX\crystalreportviewers'
I also had to add the config from that site into my web.config... and then the viewer started working properly.
Hope it helps!
I ran in the similar issue, the report was being generated correctly on the page, but when I try to Zoom, it was saying, "No valid report source is available". To overcome this issue, I simply load the report each time when page is loaded, no matter Postback or normal load.
Also make sure you are properly disposing the Crystal Report Document, otherwise it may start giving "Load Report Failed" error.
I have an ASP.NET application with pages that use reportviewer. Can someone give me a hint on how to approach the following requirement:
I want to get the report as PDF file from the page, without user interaction. I know I can render the report to a filestream, but since there's no user opening it in a browser, I need to collect the filestream from another application that might run during the night.
There might be other approaches, like a webservice for example that could return the filestream to me, but this would also mean, I have to modify the setup of the datasources that the report receives it's data from. There are a lot of controls on the page, for supplying filter parameters. By using the page life cycle I can use what's already there.
I thought about wget, but haven't tried it yet, and I'm not sure how complicated logging in will be with cookies. I do have full control over the asp.net application though, so if I can modify something there to make it easier, I'd do it.
You can use the "WebClient" in .net application to get the response from the site.
Please refer the below link:
http://msdn.microsoft.com/en-us/library/system.net.webclient(v=vs.80).aspx
this is the first time I have tried this so I am probably missing something that is staring me right in the face.
I have an ASP.NET page where the user fills in a request which then emails a PDF rendered from a ReportViewer instance.
It all works fine when I run it locally through the ASP.NET localhost but when I try and run it of the webserver it fails with the following message:
An error has occurred during report processing.
Cannot create a connection to data source 'DataSource1'.
I can preview the report via the web based report manager via http://servername/reports which works without any problem and using the report editor in VS2005.
I suspect it is something to do with the credentials but I am at a loss. The data source is set with a username and password but this is saved within the datasource.
I have been looking at this for about a day now with no joy. If anyone can point me in the right direction I would be very grateful.
Thanks
Andy
Woohoo...I managed to fix the problem.
It was the credentials after all. Even though I was specifying a username and password it was still using the webserver default credentials. I got a new user setup and it worked a treat.
As the error message didnt mention anything to do with unauthorised access and being able to pull the data through using VS2005 and the web browser for viewing the reports I thought it was the way I was referencing the report.
Thanks to those who had started to ponder about this.
I am updating an existing reporting system in ASP.NET which uses crystal reports. In the past reports have been given their parameters by session variables, however I now have a need to post them in the web address e.g.
www.mysite.com?reportname=myreport&year=2009
I have grabbed the parameters off using request.querystring as usual and the report generates and the first page looks ok. However as soon as I try to go to the next page on the report viewer toolbar the report errors getting no data.
If I remove the parameters and hard code some values the page works fine. Any ideas if this is a known issue with crystal reports? Is there a way around it?
I'm thinking it's something to do with caching not working when parameters are in the address, have something in the back of my mind about it
It seems to be an issue with crystal reports, it must use the address in some way. I modified my code to put in an intermediate page where the request.querystring variables are put into the session and then the user is forwarded to another page which generates the report.