1
Wrong filename when DocumentViewerControl.DownloadFileName is used
Problem reported by Daniel Guerriero - 12/15/2020 at 7:56 AM
Resolved
When DocumentViewerControl.DownloadFileName was specified in the code and the user opens more than one tab of the viewer for multiple files and then clicks on download or download as PDF, the suggested filename is that of the last opened viewer window instead of the corresponding file.

Example: I open a.xls then b.docx on a new tab, then go to a.xls and click "download pdf", I get b.pdf as the filename.

Tested on version 5.8.0.0

5 Replies

Reply to Thread
0
Daniel Guerriero Replied
When the user clicks con the "download" button the situation is even worse, specially when the opened files are of different type. So in the example above, a.xls gets saved as b.docx when the user clicks on download.
1
Cem Alacayir Replied
Employee Post
Probably you are using the same ID for different instances of DocumentViewer on different tabs.
stateId hash for a documentViewer instance is calculated according to documentViewer.Id + host page URL. So when you have same ID for different instances in the same host page, all instances will have the same stateId and the last loaded instance will overwrite the state (last one wins and all instances share the same state).

Solution is to change/vary documentViewer.ID inside DocumenViewerHost.aspx for different tabs.
 
For example in first tab, use documentViewer.ID="documentViewer1" and in second tab, use documentViewer .ID="documentViewer2".
 
You can also vary the documentViewer.ID according to the querystring of DocumenViewerHost.aspx.

So changing the ID will change the stateId and state will not be overwritten/shared.

Note that if you use DocumenViewerHost2.aspx (a different page) for second tab then you don't even need to change documentViewer.ID because host page path still changes stateId




0
Daniel Guerriero Replied
Thanks!
I changed the ID in the Page_Load event and that solved the problem.

If Not Page.IsPostBack AndAlso Not Page.IsCallback Then
          DocumentViewerControl.ID = "DocViewer" & Guid.NewGuid.ToString.Replace("-", "")
 End If
1
Cem Alacayir Replied
Employee Post Marked As Resolution
FYI, with DocumentUltimate v5.8.5 - January 1, 2021, we have a fix for this so you may not need your workaround anymore:

  • Improved: StatefulComponent.StateId will be uniquely generated via hashing component.Id and the host page's
    Url.PathAndQuery (e.g. /MyHostPage?q1=val1&q2=val2).This way, State conflict will be avoided when MyHostPage is loaded with different
    querystring parameters, for example in different tabs.
    In previous versions, it was generated via hashing component.Id and the host page's Url.Path (e.g. /MyHostPage) which caused a problem
    such that the last loaded instance overwrote the state (the last one won and all instances shared the same state due to same StateId).

1
Daniel Guerriero Replied
Version 5.8.5 fixed this issue, no workaround needed anymore.
Thanks!

Reply to Thread