FileExplorer not loading path

7 posts, 0 answers
  1. Jermaine
    Jermaine avatar
    13 posts
    Member since:
    Feb 2013

    Posted 25 Feb 2014 Link to this post

    The virtual and physical paths are not shown in the FileExplorer.  I cannot see any folders when running my solution.  It is designed to allow clients to select a folder path from their local filesystem.  Additionally, it needs to allow users to select a folder path from a initialpath on the server.  I was able to create a custom content provider for both task after reviewing and modifying code found in this link, http://www.telerik.com/support/kb/aspnet-ajax/fileexplorer/details/use-radfileexplorer-with-physical-and-shared-folder-s-paths , to no avail.  

    From stepping through code during debugging, I am getting the paths from the MappingFile.mapping xml file and loading them into the initialPath and viewPath properties.   


    '  Get physical and virtual path mappings to initialize the FileExplorer upon page load. This is a helper function
    ' of the ConfigureFileExplorer function
    Public Sub GetPhysicalVirtualPath()
     
        Dim configFile As New XmlDocument()
     
        Dim physicalPathToConfigFile As String = Context.Server.MapPath(Me.pathToConfigFile)
        configFile.Load(physicalPathToConfigFile)
     
        ' Load the configuration file
        Dim rootElement As XmlElement = configFile.DocumentElement
     
        Dim handlerPathSection As XmlNode = rootElement.GetElementsByTagName("genericHandlerPath")(0)
     
        ' get all mappings ;
        Me._itemHandlerPath = handlerPathSection.InnerText
     
        Me.mappedPathsInConfigFile = New Dictionary(Of String, String)()
     
        Dim mappingsSection As XmlNode = rootElement.GetElementsByTagName("Mappings")(0)
     
        ' get all mappings ;
        For Each mapping As XmlNode In mappingsSection.ChildNodes
     
            ' Get the appropriately categorized path, which is the InternalShare for ReceiveInternal and SendInternal operations
            Dim virtualPathAsNode As XmlNode = mapping.SelectSingleNode("VirtualPath")
            Dim physicalPathAsNode As XmlNode = mapping.SelectSingleNode("PhysicalPath")
     
            '  If neither string is empty, then
            If Not String.IsNullOrEmpty(virtualPathAsNode.InnerText) And Not String.IsNullOrEmpty(physicalPathAsNode.InnerText) Then
                ' Add all mappings to the list
                Me.mappedPathsInConfigFile.Add(PathHelper.RemoveEndingSlash(virtualPathAsNode.InnerText, "/"c), PathHelper.RemoveEndingSlash(physicalPathAsNode.InnerText, "\"c))
            End If
     
        Next
     
    End Sub

    The server or client directory should be shown depending on the requested action (tab's ID) received from a hidden field on the client app.  Please see the following:


     

    Public Sub GetPhysicalVirtualPath()
     
            Dim configFile As New XmlDocument()
     
            Dim physicalPathToConfigFile As String = Context.Server.MapPath(Me.pathToConfigFile)
            configFile.Load(physicalPathToConfigFile)
     
            ' Load the configuration file
            Dim rootElement As XmlElement = configFile.DocumentElement
     
            Dim handlerPathSection As XmlNode = rootElement.GetElementsByTagName("genericHandlerPath")(0)
     
            ' get all mappings ;
            Me._itemHandlerPath = handlerPathSection.InnerText
     
            Me.mappedPathsInConfigFile = New Dictionary(Of String, String)()
     
            Dim mappingsSection As XmlNode = rootElement.GetElementsByTagName("Mappings")(0)
     
            ' get all mappings ;
            For Each mapping As XmlNode In mappingsSection.ChildNodes
     
                ' Get the appropriately categorized path, which is the InternalShare for ReceiveInternal and SendInternal operations
                Dim virtualPathAsNode As XmlNode = mapping.SelectSingleNode("VirtualPath")
                Dim physicalPathAsNode As XmlNode = mapping.SelectSingleNode("PhysicalPath")
     
                ' 2/20/14 - If neither string is empty, then
                If Not String.IsNullOrEmpty(virtualPathAsNode.InnerText) And Not String.IsNullOrEmpty(physicalPathAsNode.InnerText) Then
                    ' Add all mappings to the list
                    Me.mappedPathsInConfigFile.Add(PathHelper.RemoveEndingSlash(virtualPathAsNode.InnerText, "/"c), PathHelper.RemoveEndingSlash(physicalPathAsNode.InnerText, "\"c))
                End If
     
            Next
     
        End Sub

     

    Can you clarify how the CustomFileSystemProvider.vb file should be used?  I used the example provided in the link above.  However, I removed the file operations (move, delete, etc.) since I only need to select folders from the directory to build a path to return to the client that will be used for processing needs.  Then I added the following extended provider to the end of my page's codepage:

    Public Class ExtendedFileProviderInternal
        Inherits Telerik.Web.UI.Widgets.FileSystemContentProvider
        'constructor must be present when overriding a base content provider class
        'you can leave it empty
     
        Public Sub New(ByVal context As HttpContext, ByVal searchPatterns As String(), ByVal viewPaths As String(), ByVal uploadPaths As String(), ByVal deletePaths As String(), ByVal selectedUrl As String, _
         ByVal selectedItemTag As String)
     
            MyBase.New(context, searchPatterns, viewPaths, uploadPaths, deletePaths, selectedUrl, selectedItemTag)
     
        End Sub
        Public Overloads Overrides Function ResolveDirectory(ByVal path As String) As Telerik.Web.UI.Widgets.DirectoryItem
     
            'get the directory information
            Dim baseDirectory As Telerik.Web.UI.Widgets.DirectoryItem = MyBase.ResolveDirectory(path)
     
            'remove files that we do not want to see
            Dim files As New System.Collections.Generic.List(Of Telerik.Web.UI.Widgets.FileItem)()
     
            Dim UnauthextWebConfig As String = System.Configuration.ConfigurationManager.AppSettings("UnAuthorizedFileExtensions")
     
            Dim INVALID_EXTENSIONS As String() = FileExts()
     
            For Each file As Telerik.Web.UI.Widgets.FileItem In baseDirectory.Files
     
                ' Get the file extension of the current file, the last element in the sequence
                Dim ext As String = file.Name.Split(New Char() {"."c}).Last
     
                '  For the Internal version of the file upload control, use this code
                ' along with the exclusion list in the webconfig to prevent script injection from .sql, .cs, .bat, .exe., .cmd, etc.
     
                If Not INVALID_EXTENSIONS.Contains(ext.ToLower()) Then
                    files.Add(file)
                End If
            Next
     
            Dim newDirectory As New Telerik.Web.UI.Widgets.DirectoryItem(baseDirectory.Name, baseDirectory.Location, baseDirectory.FullPath, baseDirectory.Tag, baseDirectory.Permissions, files.ToArray(), _
             baseDirectory.Directories)
     
            'return the updated directory information
            Return newDirectory
        End Function
     
        '  This function gets the custom file extension exclusion list from the web.config/ApplicationSettings set by the app admins
        Function FileExts() As String()
     
            Dim extWebConfig As String = System.Configuration.ConfigurationManager.AppSettings("AllowedFileExtensions")
     
            Dim exts As String() = extWebConfig.Split(New Char() {","c})
     
            '  If the count of extensions is not zero, then
            If (exts.Count = 0) Then
     
                exts(0) = ("undefined")
     
            End If
     
            ' Return the array
            Return exts
        End Function
    End Class


    I did not make any changes to the PathHelper.vb file.  I only kept the New(), GetFileContent(), and CheckWritePermission() functions of the FileSystem.vb file.  The CustomFileSystemProvider.vb, FileSystem.vb, MappingFile.mapping, and PathHelper.vb files are kept in my App_Data folder in Visual Studio 2010. 

    I am running/debugging the web application locally with IIS 7 on Windows 7 OS.  The application must access the shared and local directories.  Do I need to create virtual directories in IIS for the server filesystem to show in the FileExplorer?  Additionally, how can I get the FileExplorer to show the user's local File system?  What are your suggestions?  Thanks.
  2. Vessy
    Admin
    Vessy avatar
    1380 posts

    Posted 28 Feb 2014 Link to this post

    Hi Jermaine,

    I have already answered your support ticket on the subject, for convenience I will paste my answer here:


    When you are implementing a custom FileBrowserContentProvider you have to make sure that all of its methods are overriden. If you want to override just a couple of methods, you will need to subclass the built-in FileSystemContentProvider. You can find detailed information on how to work with the FileExplorer's provider and its methods in the following help article: http://www.telerik.com/help/aspnet-ajax/fileexplorer-custom-filebrowsercontentprovider.html

    On a side note, were you able to list the desired physical paths with this content provider, before the made modifications? I am asking you that because there are some possible reasons for the files and folders not to be visible in the control and most of them are connected with permission limitations:
    • you can test whether the application has all needed permissions for to view the content in the desired folders using the approach from this help article: Troubleshooting
    • in case you are working with impersonation you have to make sure that all control-related handlers have been configured with the proper permissions:
      <location path="FileSystemHandler.ashx" allowOverride="true">
          <system.web>
             <authorization>
                  <allow roles="*"/>
              </authorization>
          </system.web>
      </location>
      <location path="Telerik.Web.UI.WebResource.axd" allowOverride="true">
         <system.web>
           <identity impersonate="true" userName="HostingServer\userName" password="userPassword"/>
           <authorization>
             <allow users="*"/>
           </authorization>
         </system.web>
       </location>
    • Last but not least, you have to make sure that the paths of the control (ViewPaths/DeletePaths/UploadPaths) are set no later than the Page_Load event.

    I would suggest you first to try to configure properly the implemented by us provider in order to suppress the above assumptions as possible cause of the issues and just after that to make the desired modifications (following the instructions from the mentioned help article).



    On a side note, I would like to mention that all of the suggestions above are considering accessing paths from the Server, but not the Client machine. Please, note that accessing files and folders from a client's machine is not supported scenario which cannot be achieved with the FileExplorer control. You can find more detailed information on the subject in this forum tread.

    Kind Regards,
    Veselina Raykova
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jermaine
    Jermaine avatar
    13 posts
    Member since:
    Feb 2013

    Posted 28 Feb 2014 in reply to Vessy Link to this post

    A custom content provider wouldn't provide client file system access?  I came across other forum post that seem to suggest that it can.  Is there a control that can provide this ability?  BTW, I was able to get the file directory on the server to show using your troubleshooting advice.  Now, I need to dynamically change the initialPath to the client's file path during program execution.  You mentioned that the File Explorer should be loaded on PageLoad(), can it be loaded during program execution?  Thanks.
  5. Vessy
    Admin
    Vessy avatar
    1380 posts

    Posted 03 Mar 2014 Link to this post

    Hello Jermaine,

    RadFileExplorer cannot be used for listing files and directories from a Client's hard drive. This is not a Fileexplorer's limitation, but is a general security restriction. It is not possible to freely browse client's hard drive using JavaScript, because this will be a major security breach - actually, if this was possible, imagine how easy will be to get access to a client's personal information such as passwords, bank accounts, etc.

    This is why neither  RadFileExplorer nor other Telerik UI for ASP.NET control provides such a functionality. The only control that has access to client's file system is RadAsyncUpload, but this functionality is handled by the browser engine not by the control itself.

    Regarding the moment when the FileExplorer's paths are configured - there is no any other limitation on the way you will pass them to the control, unless this is done no later than the Page_Load event of the control's parent page. This is the latest moment of the page life-cycle when FileExplorer can obtain the made path configurations, rendering itself properly.

    Regards,
    Veselina Raykova
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
  6. Jermaine
    Jermaine avatar
    13 posts
    Member since:
    Feb 2013

    Posted 04 Mar 2014 in reply to Vessy Link to this post

    Is there a way that I can feed the FileExplorer directory and files from jQuery webmethods, into a custom file provider?  I can use HTML5 to get file and directory information on the client side.  I just need to display this in the File Explorer.  Any ideas on how I can do this?  Thanks.
  7. Vessy
    Admin
    Vessy avatar
    1380 posts

    Posted 07 Mar 2014 Link to this post

    Hi Jermaine,

    I am afraid that I have to disappoint you, but RadFileExplorer cannot be populated on the Client. The only way to achieve the desired functionality Server-side could be if the client data is taken from a 
    synchronous feed.

    Regards,
    Vessy
    Telerik

    DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

  8. Jermaine
    Jermaine avatar
    13 posts
    Member since:
    Feb 2013

    Posted 12 Mar 2014 Link to this post

    I found an alternative means for satisfying my project requirements.  Also, I was able to load the paths on the server side from the tips you suggested.  This ticket can be closed.  Thanks.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017