Quantcast
Channel: SQL Server Reporting Services, Power View Forum
Viewing all articles
Browse latest Browse all 4035

ReportExecution2005.render - Images not displayed (external, embedded or DB)

$
0
0

Platform:

SSRS 2008 R2 (SharePoint integrated mode),  WCF, ASP.NET MVC4, jQuery, VS 2010

I have created an ASP.NET MVC 4 app that render reports using the SSRS ReportExecution2005 API.

The report definitions (.rdl) are stored in the App_Data directory and loaded using the LoadReportDefinition method.  I am using the Render method and the reports are displayed correctly except that any images in the report are not displayed. I have tried the report using embedded, external and database sources for the image and cannot get the image to display.

So far only the HTML4.0 rendering format for the Render method has worked for me.

Here is some of my code:

From the Controller

public ActionResult RunReport(ReportParameters args)
{
   if (string.IsNullOrEmpty(args.ReportName) || args.ReportName == Constants.SelectPrompt)
	{
		ViewBag.ErrorMessage = "You must select a report to run.";
		return View("Error");
	}

	try
	{
		// XML, NULL, CSV, IMAGE, PDF, HTML4.0, HTML3.2, MHTML, EXCEL, Word
		byte[] rptBytes = RenderReport("HTML4.0", args);
		return File(rptBytes, "text/html");
	}
	catch (Exception ex)
	{
		ViewBag.ErrorMessage = ex.ToString();
		return View("Error");
	}
}

private byte[] RenderReport(string format, ReportParameters args)
{
	using (ReportExecutionServiceSoapClient svc = new ReportExecutionServiceSoapClient())
	{
		// svc.Credentials = System.Net.CredentialCache.DefaultCredentials;
		svc.ClientCredentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultCredentials as System.Net.NetworkCredential; 
		svc.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;

		// Load the RDL file.
		string path = HttpContext.Server.MapPath("~/App_Data/" + args.ReportName + ".rdl");
		byte[] rptBytes = System.IO.File.ReadAllBytes(path);

		Warning[] warnings;

		TrustedUserHeader trustUserHdr = new TrustedUserHeader();
		ExecutionInfo execInfo = null;
		ServerInfoHeader serverInfoHdr = null;

		ExecutionHeader execHdr = svc.LoadReportDefinition(trustUserHdr, rptBytes, out serverInfoHdr, out execInfo, out warnings);

		// Set the Parameters
		ParameterValue[] rptParams = GetReportParameters(args);
		svc.SetExecutionParameters(execHdr, trustUserHdr, rptParams, "en-us", out execInfo);

		string deviceInfo = null;
		string extension = null;
		string encoding = null;
		string mimeType = null;

		string[] streamIDs = null;
		byte[] result = null;

		// Render the report.
		svc.Render(execHdr, trustUserHdr, format, deviceInfo, out result, out extension, out mimeType, out encoding, out warnings, out streamIDs);

		return result;

	}
}
function runReport() {
    var args = {
        'ReportName': $("#lstReportName option:selected").text()
        , 'AuditId': $("#lstAudit").val()
        , 'Auditor': $("#lstAuditor option:selected").text()
    };

    $.ajax({
        url: 'Home/RunReport',
        contentType: 'application/json',
        type: 'POST',
        data: JSON.stringify(args),
        success: function (data) {
            $('#reportViewer').html(data);
        },
        error: function (jqXHR, textStatus, errorThrown) {
            alert(textStatus + ": " + errorThrown + ": " + jqXHR.responseText, "reportViewer");
        }
    });
}

The above javascript code sets the HTML for a div element (id=reportViewer) in the view.

Thanks in advance for any help.

Mark


Viewing all articles
Browse latest Browse all 4035

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>