views:

346

answers:

2

I tried to be the most descriptive I could.

Ok, so since I've never done anything like this before, I guess it's better to ask before starting at all to just don't get the whole process wrong.

We have a report that has to be called from an ASP.NET application, it could be a simple button. Through the code-behind, I gotta pass in a paramater, render the report, and don't save it anywhere, just open it to the user, as a .pdf file so he could save or print it. So please, give me links or tips, I'm reading MSDN documentation right now...

If you have any suggestion on other technologies, as for the report, I'd like to hear it, but it has to be called from ASP.NET.

Thanks in advance!

EDIT:


Now I've got the report done, I just need to know the best aproach to call it. It can't be done directly from an URL because that allows the user to save or close the pdf file, which is not what I want.

I'm starting to think that the best aproach to achieve this would be the following: I render the PDF programatically, and create the .PDF file in a temporary folder inside my app structure, then start a new thread to open the file, and wait for the user to close it, when he does, I delete the file and the thread is dead.

What do you guys think? Do y'all have a better option?

+2  A: 

Well, if the report's on the report server, probably the easiest way is just to send the user to a URL that will generate the report as needed. Try something like this in your browser address bar to see what I mean:

http://SERVER_NAME/ReportServer/Pages/ReportViewer.aspx?%2fFOLDER_NAME%2fREPORT_NAME&rs:Command=Render&rs:Format=PDF&PARAMETER_NAME=VALUE

See this knowledge base article on Report Server URLs for more details. Edit: Starting here on MSDN might help.

Matt Gibson
+1 that is the best option - just specify the report output format in the report parameters on the query string.
slugster
That would allow the user to save or open the report. But I want to open it automatically, not let the user do it.
Felipe Fiali
A: 

If you check the edit history, you'll see that I changed this completely.

Again, answering my own question:

The aproach I considered the best for doing this was:

  • Having the report in SQL Reporting Services Report Server;
  • Rendering it through code written in .NET, and capturing an array of bytes as response;
  • Writing the array of bytes to Response.OutputStream;
  • Adding an attachment header, so the file would be available as a download to the user;

Hope this helps if someone has to do the same.

Felipe Fiali