Problem with folder names with # and &

5 posts, 0 answers
  1. Loy Chan
    Loy Chan avatar
    21 posts
    Member since:
    Mar 2008

    Posted 14 Dec 2010 Link to this post

    I'm using a Custom File Content Provider (copied from the knowledge base).

    Everything works fine except the following situations:

    1. Folder name contains # or & (i.e. "Store #123")
    2. User double clicks file within this folder to view the file
    3. Within the FileSystemHandler.ashx file, the ProcessRequest function is called but the path of the file gets cut off at the # or & symbol

    So when the code gets to the WriteFile call, it fails since it can't find the file.

    Suggestions?

    Loy
  2. Mihir Pathak
    Mihir Pathak avatar
    14 posts
    Member since:
    Aug 2009

    Posted 15 Dec 2010 Link to this post

    try to encode the path. In JavaScript you can use the encodeURI() function
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Loy Chan
    Loy Chan avatar
    21 posts
    Member since:
    Mar 2008

    Posted 15 Dec 2010 Link to this post

    Hi,

    Could you please provide a little bit more info? The FileExplorer is a bit of a black box for me.

    When the user tries to open the file, I can catch this client side event with OnClientFileOpen event but where can I encode the path that eventually gets sent to the FileSystemHandler.ashx ProcessRequest method?
  5. Mihir Pathak
    Mihir Pathak avatar
    14 posts
    Member since:
    Aug 2009

    Posted 15 Dec 2010 Link to this post

    here is link
    http://demos.telerik.com/aspnet-ajax/fileexplorer/examples/applicationscenarios/filteranddownloadfiles/defaultcs.aspx

     // Tell browser to open file directly
      var requestImage = encodeURI("Handler.ashx?path=" + item.get_url());

  6. Loy Chan
    Loy Chan avatar
    21 posts
    Member since:
    Mar 2008

    Posted 15 Dec 2010 Link to this post

    Hi Mihir,

    Thanks for all your help. I was able to get it running with your direction.

    Here's what I had to use:

            function ClientFileOpen(oExplorer, args)
            {
               var item = args.get_item();
               
               if (!item.isDirectory())
               {
                   args.set_cancel(true); //this prevents the window from opening    
                   var docLoc = encodeURIComponent(item.get_path());
                   document.location = "FileSystemHandler.ashx?path=" + docLoc;
               }
            }

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017