My question is related to this link : Crystal Reports in ASP.NET MVC As per one of teh answer by coderguy123 I have written Action method at controller side ? But what will be the javascript side code ( i will be using js file to invoke this Action method )
Also , return type of action method in following method is
public ActionResult Report()
{
ReportClass rptH = new ReportClass();
rptH.FileName = Server.MapPath("[reportName].rpt");
rptH.Load();
rptH.SetDataSource([datatable]);
Stream stream = rptH.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
return File(stream, "application/pdf");
}
File .. but when i call it from js file , it is giving error .. Not sure if return type matched with datatype file ...
Basically , I want client side code to invoke this method and display the pdf file in new browser ?
I found the answer for this and forgot to update this post . As a beginner I was assuming that this can be done through $.ajax .. Returning file stream can not be done through an ajax but through direct call like window.open from client side ..
window.open('/YourController/YourAction?')
You can open the stream in both pdf and html format ..