Hello,
I'm in the process of implementing Ej2 FileManager using physical file approach which I download from: https://github.com/SyncfusionExamples/ej2-aspcore-file-provider/tree/master/wwwroot/Files
The FileManager throwing an error but if I try the API using Swagger everything working fine (returning status 200)
Error:
Success using swagger:
This is my FileManager configuration:
Is there anything I have missed?
Best regards,
Ismail
Hello Shalini,
Thank you for your feedback. I have found the problem that causing this, that is because FileManager POST did not send CSRF token. For your information, all off my API should comply with the CSRF for security reason. For now, I have disabled CSRF at API consumed by FileManager AjaxSettings by adding: [IgnoreAntiForgeryToken] to the API controller:
For complete solution, I should be able sent the CSRF token. Could you please share a way to intercept the POST from FileManager so I can add CSRF token to the "headers"? I have try that through "beforeSend" event, but still no luck. Could you please share information of how to update the "headers" before it POST ed?
Thank you
Best regards,
Ismail
|
var fileObject = new ej.filemanager.FileManager({
ajaxSettings: {
. . .
}, beforeSend: function(args) {
args.ajaxSettings.beforeSend = function(args) {
args.httpRequest.setRequestHeader('Authorization', 'CSRF-Token'); //you can pass the CSRF token here
};
}
}); |
|
public object FileOperations([FromBody] FileManagerDirectoryContent args)
{
var val = HttpContext.Request.Headers["Authorization"];
if (args.Action == "delete" || args.Action == "rename")
{
}
} |
Hi Shalini,
Thank you for your help. The answer you provide enable me to send custom header before send the ajax.
Best regards,
Ismail