asp.net - Reporting services: Get the PDF of a generated report -


i've reporting services server has running reports, , need generate them through custom website(running asp.net mvc3).

i need retrieve report stream/byte send user. no "report viewer" or so.

last time used reporting services sql 2005, , should ad reference obscure asmx file.

what's now, sql server reporting 2008 r2, .net4 , visual studio 2010? can't find tutorial explaining whole thing.

(in fact can't find tutorial there no report viewer sql 2008 r2)

several methods provided @ msdn. have used url access quick simple pdf buttons in asp .net app.

here's quick hack bit of code doing this. cleaned use integrated authentication, , there many ways store report name. (i cut , pasted old code had store report database , later return db.

// first read in report memory.  string strreportuser = "rsusername"; string strreportuserpw = "mysecretpassword"; string strreportuserdomain = "domainname";  string stargeturl = "http://sqlserver/reportserver?" +    "/myreportfolder/report1&rs:command=render&rs:format=pdf&reportparam=" +    paramvalue;  httpwebrequest req =       (httpwebrequest)webrequest.create( stargeturl ); req.preauthenticate = true; req.credentials = new system.net.networkcredential(     strreportuser,     strreportuserpw,     strreportuserdomain );  httpwebresponse httpwresp = (httpwebresponse)req.getresponse();  stream fstream = httpwresp.getresponsestream();  httpwresp.close();    //now turn around , send response.. byte[] filebytes = readfully( fstream ); // save database or file here well.  response.clear(); response.contenttype = "application/pdf"; response.addheader(     "content-disposition",     "attachment; filename=\"report " +         paramvalue + ".pdf\"" ); response.binarywrite( filebytes ); response.flush(); response.end(); 

readfully is

public static byte[] readfully( stream input ) {    using ( memorystream ms = new memorystream() )    {       input.copyto( ms );       return ms.toarray();    } }   

Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -