This is a migrated thread and some comments may be shown as answers.

IHostingEnvironment is obsolete

2 Answers 248 Views
FileManager
This is a migrated thread and some comments may be shown as answers.
Jimmy
Top achievements
Rank 1
Iron
Veteran
Jimmy asked on 19 May 2020, 08:23 AM

IHostingEnvironment used in FileManager is long obsoleted. 

Any plan to upgrade to IWebHostEnvironment soon?

thank you. 

2 Answers, 1 is accepted

Sort by
0
Ianko
Telerik team
answered on 21 May 2020, 09:45 AM

Hi Jimmy,

You are not limited to use the built-in controller to use the FileManager. The demos (https://demos.telerik.com/aspnet-core/filemanager) have been updated with detailed code to see how you can have your own controller and thus use the IWebHostEnvironment  interface instead of the IHostingEnvironment one.

Regards,
Ianko
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Nicolas
Top achievements
Rank 1
Iron
answered on 13 Jan 2023, 03:13 PM

This answer is halfway correct as Telerik (2022.3.913) ImageBrowser is still using the IHostingEnvironment for the interface IDirectoryBrowser

namespace Kendo.Mvc.UI
{
    public interface IDirectoryBrowser
    {
        IHostingEnvironment HostingEnvironment { get; set; }

        IEnumerable<FileBrowserEntry> GetFiles(string path, string filter);

        IEnumerable<FileBrowserEntry> GetDirectories(string path);
    }
}

By overwriting with the following

public interface IDirectoryBrowser
{
    IWebHostEnvironment HostingEnvironment { get; set; }
    IEnumerable<FileBrowserEntry> GetFiles(string path, string filter);
    IEnumerable<FileBrowserEntry> GetDirectories(string path);
}


we again have an issue where

private readonly IDirectoryBrowser directoryBrowser


directoryBrowser stay null therefore not accessing the directory (path issue) unless we do this which is then still using obsolete feature


protected BrowserBaseFileController(
        IDirectoryBrowser directoryBrowser,
        IDirectoryPermission permission,
        IWebHostEnvironment hostingEnvironment)
    {
        this.directoryBrowser = directoryBrowser;
        this.directoryBrowser.HostingEnvironment = (Microsoft.AspNetCore.Hosting.IHostingEnvironment)hostingEnvironment;
        this.permission = permission;
        this.HostingEnvironment = hostingEnvironment;
    }

Thanks for the feedback on how or when this be fixed.

 

Alexander
Telerik team
commented on 18 Jan 2023, 09:12 AM

Hi Nicolas,

Thank you for the provided feedback, it is not taken for granted. I will forward your feedback to our team to ensure your point of view is taken into account.

Tags
FileManager
Asked by
Jimmy
Top achievements
Rank 1
Iron
Veteran
Answers by
Ianko
Telerik team
Nicolas
Top achievements
Rank 1
Iron
Share this question
or