I'm trying to create a crystal report in asp.net mvc4 (razor syntax) in visual studio 2012. I read some articles on web that there are two ways of achieving this with razor views.
1: The simple pdf rendering without the crystalreportviewer
2: create aspx page and load crystalreportviewer on that.
I'm going with the second method where I've create an aspx page and in my controller, I have the following code.
if (this.HttpContext != null && this.HttpContext.Session != null)
this.HttpContext.Session["ReportName"] = "AccountStatement.rpt";
this.HttpContext.Session["rptSource"] = reportInfo;
In codebehind of aspnetgeneric.aspx page load, I have:
string strReportName = System.Web.HttpContext.Current.Session["ReportName"].ToString();
ReportDocument rd = new ReportDocument();
string strRptPath = Path.Combine(Server.MapPath("~/Reports"), strReportName);
if (source.GetType().ToString() != "System.String")
CrystalReportViewer1.ReportSource = rd;
Code runs fine without any exceptions on runtime but does not show the crystalreportviewer or the report itself in the browser window. (Tested on all major browsers). I tried changing the target framework to 4.0 from 4.5 but still the same.
What may i be missing? Any clues?