Intercept File Browser Ajax requests to add antiforgery token

Hi, 

"fileManagerSettings" within "RichTextEditor" appears to be a cut down model - is there any way to add the "beforeSend" handler in the setup so I can add a new form field for an antiforgery token on the fileManager ajax requests?


3 Replies

BS Buvana Sathasivam Syncfusion Team May 10, 2022 07:34 AM UTC

Hi Joseph,


Greetings from Syncfusion support.


You should be able to achieve your requirement by using the dialogOpen event. In the below sample, we have bound the beforeSend file manager event when the dialogOpen event is triggered. Please find the below code and sample for your reference.

Index.ts

let defaultRTERichTextEditor = new RichTextEditor({

  dialogOpen: dialogOpen,

});

defaultRTE.appendTo('#defaultRTE');

 

function dialogOpen(): void {

  let fileManager = document.querySelector(

    '.e-rte-file-manager-dialog .e-filemanager'

  );

  if (fileManager && !fileManager.ej2_instances[0].beforeSend)

    fileManager.ej2_instances[0].beforeSend = () => { // Provided file manager beforeSend event

      debugger;

    };

}



Samplehttps://stackblitz.com/edit/wgtggj-wbffgp?file=index.ts


API links:  https://ej2.syncfusion.com/documentation/api/rich-text-editor/#dialogopen

https://ej2.syncfusion.com/documentation/api/file-manager#beforesend


Regards,

Buvana S



JB Joseph Byrne May 10, 2022 01:08 PM UTC

Thanks - when i run your example i can see the beforeSend event being called - however it is not called on my app, 


when i put a breakpoint in 

Ajax.prototype.send (in ejs-base.js) .. 

_this.beforeSend is still null





RK Revanth Krishnan Syncfusion Team May 11, 2022 02:23 PM UTC

Hi Joseph,


As you mentioned by you we are able to catch the `beforeSend` event on the ajax call from our end in the shared application, to further validate this issue can you please share the following details,

  • The syncfusion package version you have used in your application.
  • The code snippets of the rich text editor with before send event bound.
  • If possible can you please make a simple sample on your end with issue reproducing code?


The above details will help to validate the issue and provide the solution at the earliest.


Regards,

Revanth


Attachment: BeforeSend_323d6d2a.zip

Loader.
Up arrow icon