Unable to Download the RDL Report By Calling the Function in Razor Component
Razor Component
string json = JsonConvert.SerializeObject(ModelNAME);
var response = http.PostAsJsonAsync("GenerateReport/AdmissionReport/pdf",json).GetAwaiter().GetResult();
MVC Controller
[HttpPost]
[Route("GenerateReport/{myReportName}/{ReportExtension}")]
public IActionResult index(string myReportName, string ReportExtension, [FromBody] string JsonString)
{
try
{
string path = $"{_webHostEnvironment.WebRootPath}\\Reports\\";
int ext = (int)(DateTime.Now.Ticks >> 10);
string mimetype = "";
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
Encoding srcEncoding = Encoding.GetEncoding(1251);
Dictionary<string, string> parameters = new Dictionary<string, string>();
List<Mdl_AdmissionReport> rpt = JsonConvert.DeserializeObject<List<Mdl_AdmissionReport>>(JsonString);
LocalReport lr = new LocalReport(path + "ReportName.rdl");
lr.AddDataSource("myDataSet", rpt);
parameters.Add("ReportParameter2", "ParameterNAME");
var result = lr.Execute(RenderType.Pdf, ext, parameters, mimetype);
return File(result.MainStream, "application/pdf", myReportName + ".pdf");
}
catch (Exception)
{
throw;
}
return null;
}
Can not download the File
By using the Razor Component i want to download the RDL Report from Razor Component