jQuery File Tree always uses root folder as selected folder

I am having trouble displaying data using jQuery File Tree plugin. No matter what I use for ‘root’, it always uses ‘’ and displays content of C drive!

I am using aspx (with code behind that I am not using) and a master page.

<div class="col-md-12" id="divAIMDocs">

    function openFile(file) {
        // do something with file
    $(document).ready(function () {debugger
            root: decodeURI(uploadFolder),
            script: '../assets/vendor/jquery_FileTree/connectors/jqueryFileTree.aspx',
            expandSpeed: 1000,
            collapseSpeed: 1000,
            multiFolder: false
        }, function(file) {


I added a breakpoint in venodr’s js file (below) as well as the ‘connector’ script:

$(this).each( function() {
    function showTree(c, t) {debugger  <-- this shows 't' as ''

and in connector script, jqueryFileTree.aspx:

string dir;
if(Request.Form["dir"] == null || Request.Form["dir"].Length <= 0) <-- always null
    dir = "/";
    dir = Server.UrlDecode(Request.Form["dir"]);

I then tried to hard code ‘root’ value to ‘D:SomeFolder’:

    $(document).ready(function () {debugger
            root: 'D:SomeFolder',
            script: '../assets/vendor/jquery_FileTree/connectors/jqueryFileTree.aspx',

and I see in function showTree parameter ‘t’ is now actually seeing ‘D:SomeFolder’ but connector still says Request.Form[“dir”] is null and proceeds to show content of C drive.

What a I doing wrong here?


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

As I thought, the problem was with Request.Form[“dir”]. I found this article and it pointed to an issue I wouldn’t have thought of. It is due to using FriendlyURL feature of .NET (i.e. has nothing to do with jQuery File Tree plugin).

“The HTML form in this example is designed to post to Receiver.aspx, and the Friendly URLs will take requests that include the file extension and issue an HTTP 301 – Moved Permanently response, directing the browser to make a new (GET) request for the same resource without the file extension.”

The solution was to comment out below line in RoutConfig.cs file:

public static void RegisterRoutes(RouteCollection routes)
    var settings = new FriendlyUrlSettings();
    //settings.AutoRedirectMode = RedirectMode.Permanent;

Original POST gets overwritten by subsequent GET and data is lost.

Request.Form is populated only if the page is loaded though a form POST.

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x