Click or drag to resize

Using FileUltimate in an ASP.NET Core project

To use FileUltimate in an ASP.NET Core Project, do the following in Visual Studio:

  1. Make sure you have added references to FileUltimate assemblies as described here.

    Note Note

    For an "ASP.NET Core on .NET Framework" project, make sure you have the following additional packages with these minimum versions in your project (update them in Nuget Package Manager if necessary):

    • Microsoft.AspNetCore 2.0.3+
    • Microsoft.AspNetCore.Mvc 2.0.3+
    • Microsoft.AspNetCore.Session 2.0.3+

    For an "ASP.NET Core on .NET Core" project, these dependencies will be pulled by NuGet Package Manager automatically so you don't need to do any additional steps.

  2. Open Startup.cs of your project.

    Add GleamTech to the ASP.NET Core services container. Insert the marked line into the ConfigureServices method of your Startup.cs:

    C#
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddMvc();
    
    
        //Add GleamTech to the ASP.NET Core services container.
        //----------------------
        services.AddGleamTech();
        //----------------------
    }

    Register GleamTech to the ASP.NET Core HTTP request pipeline. Insert the marked line into the Configure method of your Startup.cs:

    C#
    public void Configure(IApplicationBuilder app, IHostingEnvironment env)
    {
        if (env.IsDevelopment())
        {
            app.UseBrowserLink();
            app.UseDeveloperExceptionPage();
        }
        else
        {
            app.UseExceptionHandler("/Home/Error");
        }
    
    
        //Register GleamTech to the ASP.NET Core HTTP request pipeline.
        //----------------------
        app.UseGleamTech();
        //----------------------
    
    
        app.UseStaticFiles();
    
        app.UseMvc(routes =>
        {
            routes.MapRoute(
                name: "default",
                template: "{controller=Home}/{action=Index}/{id?}");
        });
    }

    Note that order of app.UseXXX methods is important so app.UseGleamTech should be placed before app.UseStaticFiles and app.UseMvc.

  3. Set FileUltimate's global configuration. For example, you may want to set the license key. Insert some of the following lines (if overriding a default value is required) after app.UseGleamTech call into the ConfigureServices method of your Startup.cs:

    C#
    //Set this property only if you have a valid license key, otherwise do not 
    //set it so FileUltimate runs in trial mode.  
    FileUltimateConfiguration.Current.LicenseKey = "QQJDJLJP34...";
    Tip Tip

    Alternatively you can specify the configuration in appsettings.json file.

    JavaScript
    {
      "FileUltimate:LicenseKey": "QQJDJLJP34..."
    }
    

    As you would notice, FileUltimate: prefix maps to FileUltimateConfiguration.Current and FileUltimateWeb: prefix maps to FileUltimateWebConfiguration.Current.

  4. Create a new View (eg. Index.cshtml) and insert these lines:

    C#
    @using GleamTech.AspNet.Core
    @using GleamTech.FileUltimate.AspNet.UI
    
    <!DOCTYPE html>
    @{
        var fileManager = new FileManager
        {
            Width = 800,
            Height = 600,
            Resizable = true
        };
    
        var rootFolder = new FileManagerRootFolder
        {
            Name = "A Root Folder",
            Location = "~/App_Data/RootFolder1"
        };
    
        rootFolder.AccessControls.Add(new FileManagerAccessControl
        {
            Path = @"\",
            AllowedPermissions = FileManagerPermissions.Full
        });
    
        fileManager.RootFolders.Add(rootFolder);
    }
    <html>
        <head>
            <title>File Manager</title>
            @this.RenderHead(fileManager)
        </head>
        <body>
            @this.RenderBody(fileManager)
        </body>
    </html>

    This will render a file manager component in the page which displays one root folder named "A Root Folder" which points to "~/App_Data/RootFolder1" with Full permissions.

    Tip Tip

    Alternatively you can add the namespaces globally in Views/_ViewImports.cshtml to avoid adding namespaces in your pages every time.

    If you need a standalone file uploader component, insert these lines instead:

    C#
    @using GleamTech.AspNet.Core
    @using GleamTech.FileUltimate.AspNet.UI
    
    <!DOCTYPE html>
    @{
        var fileUploader = new FileUploader
        {
            Width = 600,
            Height = 300,
            Resizable = true,
            UploadLocation = "~/App_Data/Uploads"
        };
    }
    <html>
    <head>
        <title>File Uploader</title>
        @this.RenderHead(fileUploader)
    </head>
    <body>
        @this.RenderBody(fileUploader)
    </body>
    </html>