ReportViewer cannot find data source remotely - asp.net

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.

Related

Printing Crystal Reports from a Crystal Reports Viewer (ActiveX, ASP.Net)

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.

Login to asp.net site from another app, then receive filestream

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

Could not render the url. Could not get image from url.Navigation timeout

I've got a ASP.NET web application which contains the Winnovative HTML to PDF Converter.
This has been running for over a year successfully generating PDFs
However, this is no longer working, and the error being returned is:
Could not render the url. Could not get image from url.Navigation timeout..
I've checked the Winnovative FAQ and they suggest adding a NavigationTimeout to the instance of the PdfConverter. I've added the following:
PdfConverter.NavigationTimeout = 500
However, this has not fixed the error. Furthermore, the page being converted only takes a fraction of a second to load when loading directly in the browser, so I don't believe its a performance issue with the page being rendered.
Has anyone experienced this problem before? Are there any known solutions/causes for this?
In the end I found out this error was occuring because we were trying to request a PDF from a HTTPS file.
I weren't able to solve why though.
Please see this question if you have an answer:
Generating PDF from HTTPS causes error
If anyone else gets this error: In our case, running on IIS 8.5, changing the application pool from ApplicationPoolIdentity to Network Service fixed it. So it seems it is a folder permission problem. Network service isn't ideal and really the actual folder permissions should be set.

ASP.NET crystal report parameters from query string not working

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.

Why would an aspx file return 404 ("The page cannot be found")

Why when I access an aspx (e.g., http://www.example.com/foo.aspx - not the real site) through IE6 would I get a 404 Error (i.e., "The page cannot be found") in IIS6
I've got scripts enabled for the website and I've tried with executables enabled as well.
Here is the full error:
The page cannot be found
The page you are looking for might have been removed, had its name changed, or
is temporarily unavailable.
------------------------------------------------------------------------------
Please try the following:
Make sure that the Web site address displayed in the address bar of your
browser is spelled and formatted correctly.
If you reached this page by clicking a link, contact the Web site
administrator to alert them that the link is incorrectly formatted.
Click the Back button to try another link.
HTTP Error 404 - File or directory not found.
Internet Information Services (IIS)
------------------------------------------------------------------------------
Technical Information (for support personnel)
Go to Microsoft Product Support Services and perform a title search for the
words HTTP and 404.
Open IIS Help, which is accessible in IIS Manager (inetmgr), and search for
topics titled Web Site Setup, Common Administrative Tasks, and About Custom
Error Messages.
I can get to Default.htm in the same directory, so I know the path is right. I've opened it up to everyone (temporarily) so I know the permissions are right.
It could be a lot of things. I had this issue today because .NET had not been re-initialized after installing IIS (aspnet_regiis -i -enable or equivalent).
Check that the anonymous user under which the site runs has read access to the file foo.aspx.
IIS6 and later uses a 404 response, thereby not letting an attacker know whether such a file even exists.
I just happened to find another culprit for this issue. My foo.aspx page referenced a particular master page that had a <%# Register %> directive to a user control that did not exist. Removing the reference to the non-existent user control caused my foo.aspx to load instead of 404.
I found a solution here.
The real catch was using this:
Response.TrySkipIisCustomErrors = true;
The site is pointing to a different directory where the page is not.
It could be permissions, however I would think you would get an access error instead.
I'm assuming you are running IIS.
Check that www.example.com is going to the site that you think it is.
If you are hosting multiple sites on the same IP using host headers you may want to double check the name you are using is going to the site you think it is.
Ray and Joe probably have it. In order to serve any file type, IIS has to have a mapping for it. Aspx files require that they be mapped to the AspNet ISAPI dll, which the .Net installation normally takes care of. If you install IIS after .Net (and I'm sure there are other situations), you have to initiate this yourself by running aspnet_regiis.
ALTERNATE SOLUTION (same error perhaps different cause).
I had installed Visual Studio 2008 Pro without SQL Express it, and it caused this same error. Reinstallation of VS2008 with sql express included seemed to have corrected the problem, or perhaps the install took other actions. I did try to register ASP.net numerous times prior but no luck however it is definitely the most probable cause Just posting my experience for those pulling their hair as I was..
Thanks
If you register the .NET 4 version of IIS, you may find it's grabbed the registration of the aspx extension. If ASP.NET v4 is prohibited then 404 will be returned
I had this issue where some customers were reporting the 404.0 and some didn't have the problem at all(same page). I was able to navigate to any of the pages with no problems from my machine. Some customers would refresh and it would go away. I am using .Net 4.5.2 and IIS 7.5.
Looking at the IIS log file I would see:
sc-status sc-substatus sc-win32-status
404 0 2
sc-status.sc-substatus: 404.0 - Not Found
sc-win32-status: 2 - ERROR_FILE_NOT_FOUND
https://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs.85).aspx
https://en.wikipedia.org/wiki/HTTP_404
I found the problem was I had deployed a new version of the website in which the old version of the website had RouteConfig.cs/FriendlyUrlSetting setup by creating a project using the web forms template. The new version was created using an empty template. So obvious to me now.. no URL routing. Customers had a cache issue with certain pages on their machine(no .aspx extension) and having them clear browser data ultimately fixed the problem.
I got this issue when I tried using a different drive to host my apps. I ended up moving them to the wwwroot folder because it was working there and I did not have to time figure out why it is not working on the E:\ drive.
I had bin\roslyn compiler missing. Adding that all worked fine.
Check for double quote errors. I started getting a 404 on a single page because I accidentally had this:
<asp:TemplateField HeaderText="ImageURL"">
instead of this:
<asp:TemplateField HeaderText="ImageURL">
For an aspx page, error 404 can be quite misleading! I have seen all the answers and they presuppose assuming various issues with the file, page, path, etc. but the simplest issues is the fact that if there is an error in your asp page (i.e bad format, improper usage of control, etc. asp will think the page does not exist and will post a 404 when in all actuality, it is easy to ascertain if there is a bad format by simply clicking on design mode. If the page does not render no need to do anything else but look at what is causing the render error, fix and viola'! Your page shows since it was never missing or can't be found, but it simple did not know how to display! Too often people go looking for the wrong solutions and waste so much time! Hope this helps somone. :-)

Resources