This is a migrated thread and some comments may be shown as answers.

MVC3 - Programmatic report image renders blank

1 Answer 55 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Pr3vention
Top achievements
Rank 1
Pr3vention asked on 15 Apr 2013, 03:59 PM
I am trying to render a report as an image in my web service and return a byte[] to my client. The byte[] is then converted back into an image for display in the browser. From my debug sessions, I can see that byte[] does have data in it and the view appears to have a correctly sized image; however, the image is completely blank.

This report in particular requires one Integer parameter, ArgID, to be passed in. Blank values can not be accepted. Below is the code I am using (function names and arguments have been modified for brevity).

Web-Service code to render the report as an image:
public byte[] GetReport(int ArgID)
{
    try
    {
        Telerik.Reporting.Processing.ReportProcessor proc = new Telerik.Reporting.Processing.ReportProcessor();
        Telerik.Reporting.InstanceReportSource irs = new Telerik.Reporting.InstanceReportSource();
  
        Report1 report = new Report1();
        report.ReportParameters.Add(new Telerik.Reporting.ReportParameter("ArgID", Telerik.Reporting.ReportParameterType.Integer, ArgID));
        irs.ReportDocument = report;
  
        RenderingResult item = proc.RenderReport("IMAGE", irs, null);
        return item.DocumentBytes;
    }
    catch (Exception ex)
    {
        throw new FaultException(new FaultReason(ex.ToString()));
    }
}

View file img tag:
@model int
<
img src="@Url.Action("GetReport", "Report", new { ID = Model })" alt="" />

Action called from img tag:
[HttpGet]
public ActionResult GetReport(int ID)
{
    byte[] img;
    using (var client = new MyService.MyServiceClient())
    {
        img = client.GetReport(ID);
    }
    return File(img, "image/tiff");
}


I've only just started using Telerik Reporting over SSRS and would like to make the case for switching to Telerik for a long-term solution if I can manage to get programmatic generation working within specifications. Any and all support is greatly appreciated.

Thank you,
-J

1 Answer, 1 is accepted

Sort by
0
Pr3vention
Top achievements
Rank 1
answered on 15 Apr 2013, 04:25 PM
Please disregard this thread. After further investigation, the issue is coming from an unhandled exception somewhere in our backend system.

Thank you,
-J
Tags
General Discussions
Asked by
Pr3vention
Top achievements
Rank 1
Answers by
Pr3vention
Top achievements
Rank 1
Share this question
or