I have one SSRS report URL which if I enter that URL in the browser then it shows the SSRS report with Print and Save option like:
Which works fine on the browser.
What I want, there is one button on .cshtml
page so by clicking on that button I need to download the report on client browser.
URL: http://xyz/ReportS/report/UAT/SampleReport_V1?Srno=X123
What I tried:
by setting &rs:Format=PDF
and made a HTTP Request from Asp.Net Core Application but it generated PDF but in corrupt format.
Code:
public void Download_SSRSInPDF()
{
string URL = "http://xyz/ReportS/report/UAT/SampleReport_V1";
string Command = "Render";
string Format = "PDF";
URL = URL + "?SrNo=X123&rs:Command=" + Command + "&rs:Format=" + Format;
System.Net.HttpWebRequest Req = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(URL);
Req.Credentials = System.Net.CredentialCache.DefaultCredentials;
Req.Method = "GET";
string path = @"E:New folderTest.pdf";
System.Net.WebResponse objResponse = Req.GetResponse();
System.IO.FileStream fs = new System.IO.FileStream(path, System.IO.FileMode.Create);
System.IO.Stream stream = objResponse.GetResponseStream();
byte[] buf = new byte[1024];
int len = stream.Read(buf, 0, 1024);
while (len > 0)
{
fs.Write(buf, 0, len);
len = stream.Read(buf, 0, 1024);
}
stream.Close();
fs.Close();
}
How to do it in Asp.Net Core?
EDIT::
I have that asmx url of my report:
http://server-name/ReportServer/reportexecution2005.asmx
But unable to proceed with this, can someone points me towards documentation?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…