Can anyone help me to save the chart control temporary image files on SharePoint 2010 document library/picture library. Actually in my standalone environment the webpart is working fine when using c:\TempImageFiles folder for storing the temp image files. But my client's production environment is having more servers with load balancing and the webpart is not working as expected in place of showing charts webpart shows a "X" sign on the top of image/chart. I used chart.ImageLocation = SPContext.Current.Web.Lists["TempImage"].DefaultViewUrl + "/ChartPic_#SEQ(200,30)";
with allow unsafe update as true, but without success. It is throwing javascript errors as Message: Sys.WebForms.PageRequestManagerServerErrorException: Could not find a part of the path 'C:\inetpub\wwwroot\wss\VirtualDirectories\8080\siteURL\TempImage\Forms\AllItems.aspx\ChartPic_000001.png'. Any help in this regard will be appreciable.
2 Answers
When using Load balanced environment the request might not go to the same server where actually the chart image is created. One way to resolve this is setting "IP Affinity" on your load balancer, that shall direct the ongoing requests from a client to the same server where it furnished preceeding requests. Another way is use a UNC path shared across all servers, but that may hinder due to security restrictions in production environment.
Update : @DeepakSemwal , I did not do it myself, but can give a possible way of doing it, looking at the links you referred. Web.config setting.
<appSettings>
<add key="ChartImageHandler" value="storage=file;dir=[you doclib url];"/>
</appSettings>
you might need to give necessary permission on this lib(probably to the 'Network service' or ASPNET_user).
Set chart properties like that (or may be programmatically set it)
<asp:Chart ID="chart" runat="server" Width="500" Height="350"
ImageStorageMode="UseImageLocation"
ImageType="Png"> ...
</asp:Chart>
while setting the image location in code like
string newUrl = SPContext.Current.Web.Url +"/"+ [doclib].RootFolder.Url; // where doclib is your imageslibrary
chart.ImageLocation = newUrl ;
See if it can work for you.
-
Hi Furqan, thanks for your quick rpl.. is it possible to store the chart control's temporary images in SharePoint document library/ Picture Library ? If yes then Hows ?Deepak Semwal– Deepak Semwal2012-06-18 07:59:40 +00:00Commented Jun 18, 2012 at 7:59
-
@Deepak IMHO, it might not be possible.Furqan Hameedi– Furqan Hameedi2012-06-18 08:24:01 +00:00Commented Jun 18, 2012 at 8:24
-
Hi Furqan, Please have a look link, Roman putting his inputs to save the image in document library.Deepak Semwal– Deepak Semwal2012-06-20 13:59:54 +00:00Commented Jun 20, 2012 at 13:59
-
Hi Furqan, Manish Joshi also describing to save the temp images in document library link, but when I am trying the same getting javascript errors. Can you help?Deepak Semwal– Deepak Semwal2012-06-20 14:51:20 +00:00Commented Jun 20, 2012 at 14:51
-
@DeepakSemwal , I updated a answer based on the links you pointed. Though I am not sure 100% for this to work, lets just give it a try.Furqan Hameedi– Furqan Hameedi2012-06-21 07:47:28 +00:00Commented Jun 21, 2012 at 7:47
I think I got a answer for my query, to store the chart images in SharePoint document library we need to map a document library to a hard disc drive (as I did z:) and then set the chart image handler as: <add key="ChartImageHandler" value="storage=file; timeout=3600; url=Z:\;"/> for this to work porperly we also need to change the script manager's async postback timeout property to 3600 as AsyncPostBackTimeOut="3600". The process is taking around 3 minutes (as it first creating the chart images in document library and then downloading those) in my environment which is bit high for the users to wait that much long :( so again searching for some methods that can make the process faster. Hope this can help someone.