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

Notification link to download file issues #7868


User avatar
0
URITECHNOLOGY created

When we import users, we receive a notification which allows us to click the description to download the file summary. After a minute or so, the link is no good. I'm assuming this is because the cache is release? When this happens, a new tab opens with this JSON string: {"result":"Requested file does not exist!","targetUrl":null,"success":true,"error":null,"unAuthorizedRequest":false,"__abp":true}

So we want to know if we have some options to work around this user experience issue: 1. How can we stop the file from being 'released' from cache so it can be accessed forever? Or, 2. Can we create an 'expiration' on the notification so that it is deleted when the file is removed from cache so that the user does not have a bad experience clicking the link and viewing the JSON string. Or, 3. Can we create a modal alert to let the user know when they click the link that the notification window has expired and the user needs to retry the operation? (least best option)

We are utilizing the same workflow for a PDF export that we have built into our application. The user kicks off a job that is a long running process to create a set of PDF invoices. When these are ready, the user recieves a notification and can access the file from their notifications, however, just like the user import, after a minute or so, the link is no longer working and we get the JSON string.

Please advise.


10 Answer(s)
  • User Avatar
    0
    URITECHNOLOGY created

    We get support with our yearly license correct? I need support on this question ASAP.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Sorry for our late reply.

    You can change the expiration here https://github.com/aspnetzero/aspnet-zero-core/blob/dev/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Core/Storage/TempFileCacheManager.cs#L19.

    1. Can we create an 'expiration' on the notification so that it is deleted when the file is removed from cache so that the user does not have a bad experience clicking the link and viewing the JSON string. Or,

    This is possible using using https://aspnetboilerplate.com/Pages/Documents/Background-Jobs-And-Workers. You can create an background job which executes after 1 min (or the expiration time you are willing to use) and it can delete the notification.

    Actaully this must be in AspNet Zero, we will implement it. Thank you for pointing this out.

    1. Can we create a modal alert to let the user know when they click the link that the notification window has expired and the user needs to retry the operation? (least best option)

    By default, the href of the notification link item redirects user to a download page. So, In order to do what you want, there will be many changes.

    If you want persistant storage for your generated files, you can store them using IBinaryObjectManager which stores items in database. But, don't forget that, it will cause problems if you are using more than one database instace for your app.

  • User Avatar
    0
    URITECHNOLOGY created

    Thank you this should get us looking in the right direction.

    Also, do you know why we would be receiving multiple notifications for the same thing? It's like it's duplicating the same notification when the job finishes.

  • User Avatar
    0
    ryancyq created
    Support Team

    Hi, do you mean there are multiple notifications of the same download link being created?

  • User Avatar
    0
    URITECHNOLOGY created

    Yes

  • User Avatar
    0
    URITECHNOLOGY created
    //tried this but generated up to 4 notifications, none of them returned a file
    //_appNotifier.MarketingInvoiceGenerated(input.User, file.FileToken, file.FileType, file.FileName);
    
    //current implementation
    if (file != null)
                {
                    _appNotifier.MarketingInvoiceGenerated(input.User, file.FileToken, file.FileType, file.FileName);
    }
    //tried this and it generates up to 3 notifications, some times the link works, sometimes not
    //AsyncHelper.RunSync(async () => await _appNotifier.MarketingInvoiceGenerated(input.User, file.FileToken, file.FileType, file.FileName));
    

    IN the appnotifier.cs page we have added: AppNotifier.cs

    public async Task MarketingInvoiceGenerated(UserIdentifier argsUser, string fileToken, string fileType, string fileName)
            {
                var notificationData = new LocalizableMessageNotificationData(
                    new LocalizableString(
                        "ClickToSeeMarketingInvoices",
                        PortalConsts.LocalizationSourceName
                    )
                );
    
                notificationData["fileToken"] = fileToken;
                notificationData["fileType"] = fileType;
                notificationData["fileName"] = fileName;
    
                await _notificationPublisher.PublishAsync(AppNotificationNames.DownloadMarketingInvoices, notificationData, userIds: new[] { argsUser });
            }
    
    
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @URITECHNOLOGY

    Are you running more than one instance of your app ?

  • User Avatar
    0
    URITECHNOLOGY created

    In staging: Site is load balanced for 2 domains:

    • wrmgincentives.uritechnology.com
    • wrmgportal.uritechnology.com Both domains resolve to the same hosted folder on each server (A and B servers) All instances share the same database.

    In Production: We have it deployed to two different servers for 2 different domains.

    • wrmgincentives.com is load balanced
    • wrmgportal.com is single server instance All instances share the same database.

    How would this setup affect the site to produce multiple duplicate notifications?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @URITECHNOLOGY

    Notifications are distributed by background jobs. Could you try to disabled background jobs in one of your instances ?

  • User Avatar
    0
    ismcagdas created
    Support Team

    This issue is closed because it has not had recent activity for a long time.