Hi, i'm having an issue regarding export file to excel, using the EpPlusExcelExporterBase sometimes it works, sometimes it shows
{"result":"Requested file does not exist!","targetUrl":null,"success":true,"error":null,"unAuthorizedRequest":false,"__abp":true}
i've already update the file cache expiration to 3 minutes instead of 1 minute based on this ticket https://support.aspnetzero.com/QA/Questions/7868 still exporting is not consistent, am i missing something? Please advise, Thanks
7 Answer(s)
-
0
Hi @zyrel.sermon
Sorry for our late reply.
- Do you use Redis or any other cache prodider or do you use memory cache ?
- Does your app have more than one instance running on production ?
-
0
Hi
Do you use Redis or any other cache prodider or do you use memory cache ? ** we use memory cache Does your app have more than one instance running on production ? ** yes our app is running in multiple instance
-
0
yes our app is running in multiple instance
hi, You should use the redis in the situation
-
0
Hi is there any sample code snippet or docs on how we can implement redis cache in exporting file? Thanks
-
0
hi @zyrel.sermon
https://aspnetboilerplate.com/Pages/Documents/Caching#redis-cache-integration
-
0
Hi
We're using the IDistributedCache to set and get data cache from redis and we're able to see logs set/get from redis, there are times that the exporting is successful and there are times that the "Requested file does not exist!" occurs is it possible that the keys we're getting are already expired?
here's a sample code
protected FileDto CreateExcelPackage(string fileName, Action<ExcelPackage> creator) { var file = new FileDto(fileName, MimeTypeNames.ApplicationVndOpenxmlformatsOfficedocumentSpreadsheetmlSheet); string cacheString; var cacheToken = _distributedCache.Get(fileName); if (cacheToken != null) { cacheString = Encoding.UTF8.GetString(cacheToken); file = JsonConvert.DeserializeObject<FileDto>(cacheString); } else { using (var excelPackage = new ExcelPackage()) { creator(excelPackage); Save(excelPackage, file); } cacheString = JsonConvert.SerializeObject(file); cacheToken = Encoding.UTF8.GetBytes(cacheString); var options = new DistributedCacheEntryOptions() .SetSlidingExpiration(TimeSpan.FromMinutes(1)) .SetAbsoluteExpiration(DateTime.Now.AddMinutes(30)); _distributedCache.Set(fileName, cacheToken, options); file = this.CreateExcelPackage(fileName, creator); } return file; }
are we doing it wrong? please advise thanks
-
0
hi @zyrel.sermon
Why are you using
IDistributedCache
instead of abp cache?