Sharing Documents

  • 3 minutes to read

The current approach implemented by DevExpress Office Controls for storing all open documents in server memory (in a list maintained by the DocumentManager) does not prevent scenarios in which the same document is opened by multiple browser clients at the same time.

These situations may occur in the following cases.

  • A document is opened from a common shared document folder on the server file system (this folder is specified using the WorkDirectory property of an office control). Multiple users open the same document file specified by its server path - its location within the shared folder.

    Document opening can be initiated through an office control's UI (via the File Open dialog) or using an API (via an Open method that accepts pathToDocument as a parameter).

  • Specify the DocumentId to open a document directly from the server’s in-memory storage of open documents (DocumentManager) by specifying the DocumentId.

    You can open a document through an API via an Open method that accepts IDocumentInfo as a parameter) – as demonstrated in the code snippet below.

    var documentId = GetSharedDocumentId(); 
        var documentInfo = (SpreadsheetDocumentInfo)DocumentManager.FindDocument(documentId);

    Note, that an office control’s Open method only receives the IDocumentInfo class's descendant that is cast for the specific type as a parameter (SpreadsheetDocumentInfo and RichEditDocumentInfo, respectively).

    If this code is called with the same DocumentId on behalf of different application users, actions performed by such users within the document will be applied to the same document on the server.

Currently, changes made by other users to the same document are not indicated in DevExpress office controls’ UI. End users may need to refresh the web page to see other user’s changes.

Document sharing may cover scenarios in which an end-user starts working with a document on one computer (for instance, a desktop) and then continues his/her work on another computer (such as a tablet). In this case, the user does not lose changes when switching betweendevices. Other scenarios such as collaboration or co-authoring can also lead to losing changes.

To learn more about document sharing, refer to the following Knowledge Base articles.

Prevent Document Sharing

To disable document sharing, use the following approaches.

  • If documents are opened from the server's file system, divide user documents into different working folders (specified by the WorkDirectory property) for different users (user accounts).
  • If documents are opened from a custom document storage (e.g., a database), implement custom logic that will check and prevent requests from different users (user accounts) to a database document object with the same DocumentId.