Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Excel Export Requested file does not exist! #9489


User avatar
0
zyrel.sermon created

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)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @zyrel.sermon

    Sorry for our late reply.

    1. Do you use Redis or any other cache prodider or do you use memory cache ?
    2. Does your app have more than one instance running on production ?
  • User Avatar
    0
    zyrel.sermon created

    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

  • User Avatar
    0
    maliming created
    Support Team

    yes our app is running in multiple instance

    hi, You should use the redis in the situation

  • User Avatar
    0
    zyrel.sermon created

    Hi is there any sample code snippet or docs on how we can implement redis cache in exporting file? Thanks

  • User Avatar
    0
    maliming created
    Support Team

    hi @zyrel.sermon

    https://aspnetboilerplate.com/Pages/Documents/Caching#redis-cache-integration

  • User Avatar
    0
    zyrel.sermon created

    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

  • User Avatar
    0
    maliming created
    Support Team

    hi @zyrel.sermon

    Why are you using IDistributedCache instead of abp cache?