Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Folder/File browser with MVC 2?

How can you create a route that accept an undefined number of strings? The folder browser should be able to browse the specified folder and all the sub folders. Using JQuery to get the folders back from the server. The problem is how to build the JQuery?

$.ajax({
           type: "POST",
           url: "http://localhost:30218/Data/Folder1/Folder2/etc",
           dataType: "json",
           success: function (data) { }
       });

I mean, how can you create a MVC 2 url that could be like 10 subfolders deep? I don't want to define a static number of maximum folders that it can contain. How can you create the url and what routing should you use? Querystrings for subfolders?

like image 816
Patrick Avatar asked Aug 20 '26 05:08

Patrick


1 Answers

You can use the catchall on the last route segment, which is the asterisk character, like so:

"Files/{action}/{*path}"

That would cause everything at the end to be lumped together in the path parameter.

like image 89
Andrew Barber Avatar answered Aug 23 '26 00:08

Andrew Barber



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!