/// <summary> /// Retrieves the content of a given folder. /// </summary> /// <param name="path">The folder's path, which content will be served.</param> /// <returns>A <see cref="JsonResult"/> containing folder's files and child folders.</returns> /// <exception cref="HttpException">Throws 403 Forbidden if the supplied <paramref name="path"/> is outside of the valid paths.</exception> /// <exception cref="HttpException">Throws 404 File Not Found if refered folder does not exist.</exception> public virtual JsonResult Browse(string path) { path = NormalizePath(path); if (AuthorizeBrowse(path)) { try { directoryBrowser.Server = Server; var result = new BrowseResult { Files = directoryBrowser.GetFiles(path, Filter), Directories = directoryBrowser.GetDirectories(path), Path = pathProvider.AppendTrailingSlash(path), ContentPaths = ContentPaths.Select(root => pathProvider.ToAbsolute(root)).ToArray() }; return(Json(result)); } catch (DirectoryNotFoundException) { throw new HttpException(404, "File Not Found"); } } throw new HttpException(403, "Forbidden"); }