Does anyone know if there is a way in the report definition to force a unique streamid for report images per request. I have a situation where I am rendering a report as a byte[] via the ReportExecutionsService web api. Whenever a report has images SSRS will give each image a streamid and I am required to save the parts to a temp web folder the client can access.
When I put a chart on a report the streamID never changes and this is causing a cache issue in browsers. The same chart displayed regardless of parameters, however, I can view the temp file on the server and see that the chart has been updated.
Posting a workable solution in case anyone is interested.
A. Calculate the physical and virtual mapping to a temp folder in your controller methods. a. NOTE : For reports with charts you should create a folder per request for the report. I used:
private string GetVirtualTempFolder()
{
if (Url != null)
return Url.Content("~/Temp/");
else
return VirtualPathUtility.ToAbsolute("~/Temp/");
}
private string GetPhysicalTempFolder()
{
return AppDomain.CurrentDomain.BaseDirectory + @"Temp\";
}
...
string virtualTempFolder = "";
string physicalTempFolder = "";
if (makeUniqueTempFolder)
{
virtualTempFolder = this.GetVirtualTempFolder();
physicalTempFolder = this.GetPhysicalTempFolder();
string unique = Guid.NewGuid().ToString();
virtualTempFolder = virtualTempFolder + unique + "/";
physicalTempFolder = physicalTempFolder + unique + "/";
System.IO.Directory.CreateDirectory(physicalTempFolder);
}
B. Pass the directory names into your reporting services wrapper layer. I am using a DI so the signatures needed to be modified.
C. In the ReportingServices Rendering api you can pass the chosen virtual directory to pull temp files associated with streams via the DeviceInfo interface.
D. The streamIDs are returned in the Render method. Iterate and save them to the calculated physical location.
While I already had the temp folder functionality working, I had to add the ability to optionally create a temp location per request.
来源:https://stackoverflow.com/questions/20055284/ssrs-streamids-and-chart-images-render-with-same-id-for-different-requests