This example shows DevExtreme FileManager, which is bound to a default file sytem provider. The page handler methods work as backend here.
Files to look at:
• Index.cshtml• Index.cshtml.cs
• _Layout.cshtml
Implementation: 1. Add required libraries to your project:(https://docs.devexpress.com/AspNetCore/401026/devextreme-based-controls/get-started/configure-a-visual-studio-project))Note The project targets .NET Core 3.0. To run the project in Visual Studio 2017, change the target framework in the project settings.
2. Add File Manager control to your Razor Page and use the Remote provider.
[C#]@(Html.DevExtreme().FileManager().FileProvider(provider=>provider.Remote().Url(Url.Page("Index","Documents")))
3. File Manager uses both GET and POST requests, so it's necessary to create handlers for both request types:[C#]publicIActionResultOnGetDocuments(FileSystemCommandc,stringa)=>ProcessFileApiRequest(c,a);publicIActionResultOnPostDocuments(FileSystemCommandc,stringa)=>ProcessFileApiRequest(c,a);
4. Process requests with IFileProvider like in the Physical File System demo. Since all data operations except Download return JSON data, return the result in the handler as follows:[C#]returncommand==FileSystemCommand.Download?(IActionResult)result:newJsonResult(result);
5. Disable AntiForgeryToken in the Razor Page with File Manager via IgnoreAntiforgeryTokenAttribute.