Turning FileProvider into a log

I'd like to log certain actions from the FileManagerController.cs file in the EJ2ASPMVCFileProvider repo (such as upload) and display them on the hosted website.  I think I need to add something to _Layout.cshtml, but I'm not sure where to begin.


5 Replies

KR Keerthana Rajendran Syncfusion Team February 9, 2022 03:28 PM UTC

Hi William, 

Thanks for contacting Syncfusion support.  

We are quite unclear about the exact requirement in rendering File Manager with EJ2ASPMVCFileProvider. However, please refer to the below links which might be helpful. 

For getting started with File Manager, refer to the following link. 



Refer to the below code, where upload action is handled in EJ2ASPMVCFileProvider. 


Please elaborate on your exact requirement with File Manager so that we can check and serve you better. 

Regards, 
Keerthana R. 





WI William February 10, 2022 02:48 AM UTC

Sorry for the confusion.  I would like to add html elements to the _Layout.cshtml file from the FileManagerController.cs file.  For example, when the Upload ActionResult gets called, I would like to add an paragraph tag to _Layout.cshtml file.



SA Shameer Ali Baig Sulaiman Ali Baig Syncfusion Team February 10, 2022 03:59 PM UTC

Hi William, 
 
We suspect that you are expecting to show some HTML content in Layout page when files are uploaded in the FileManager. You can achieve this requirement by updating the content of the HTML element available in the layout page in the success event of FileManager component. 
 
[Index.cshtml] 
    <ejs-filemanager id="file" success="OnSucess"> 
        <e-filemanager-ajaxsettings url="/Home/FileOperations" 
                                    downloadUrl="/Home/Download" 
                                    uploadUrl="/Home/Upload" 
                                    getImageUrl="/Home/GetImage"> 
        </e-filemanager-ajaxsettings> 
    </ejs-filemanager> 
    <!-- end of filemanager element --> 
</div> 
 
<script> 
 
    function OnSucess(args) { 
        if (args.action == "Upload") { 
            document.getElementById("dynamicContent").innerHTML = "FileManager Upload success"; 
        } 
    } 
} 
 
[_Layout.cshtml] 
<body> 
    <header> 
        <nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3"> 
            <div class="container"> 
                <a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">WebApplication1</a> 
                <button class="navbar-toggler" type="button" data-toggle="collapse" data-target=".navbar-collapse" aria-controls="navbarSupportedContent" 
                        aria-expanded="false" aria-label="Toggle navigation"> 
                    <span class="navbar-toggler-icon"></span> 
                </button> 
                <div class="navbar-collapse collapse d-sm-inline-flex flex-sm-row-reverse"> 
                    <ul class="navbar-nav flex-grow-1"> 
                        <li class="nav-item"> 
                            <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a> 
                        </li> 
                        <li class="nav-item"> 
                            <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a> 
                        </li> 
                        <li class="nav-item nav-link text-dark" id="dynamicContent"></li> 
                    </ul> 
                </div> 
            </div> 
        </nav> 
    </header> 
    <div class="container"> 
        <main role="main" class="pb-3"> 
            @RenderBody() 
        </main> 
    </div> 
 
    <footer class="border-top footer text-muted"> 
        <div class="container"> 
            &copy; 2020 - WebApplication1 - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a> 
        </div> 
    </footer> 
    <script src="~/lib/jquery/dist/jquery.min.js"></script> 
    <script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script> 
    <script src="~/js/site.js" asp-append-version="true"></script> 
    @RenderSection("Scripts", required: false) 
    <!-- Syncfusion Essential JS 2 ScriptManager --> 
    <ejs-scripts></ejs-scripts> 
</body> 
 
 
We have attached the sample with the above solution in the attachment. 
 
Regards, 
Shameer Ali Baig S. 



WI William February 11, 2022 06:24 AM UTC

Thanks for your reply, this is almost what I'm looking for.  However, I am not adding the file manager instance in the same project.  I'm using the FileProvider project as a standalone server that gets connected to from a separate project with the file managers.  So, I can't get innerHTML like you do in Index.cshtml.  Is there any way to modify _Layout.cshtml from FileManagerController.cs instead?



SA Shameer Ali Baig Sulaiman Ali Baig Syncfusion Team February 14, 2022 07:22 AM UTC

Hi William, 
 
You can achieve this requirement by using AJAX in FileManager’s success event to call controller action, then can add partial view into _Layout.cshtml page. 
 
Please, refer the following forum to achieve your expected requirement. 
 
 
 
 
Please, let us know if you need any further assistance. 
 
Regards, 
Shameer Ali Baig S. 


Loader.
Up arrow icon