Hello, how could I pass arguments in it so that the path of the PhysicalFileSystemProvider is dynamic?
FileManager for ASP.NET Core - How to pass arguments to Web API part from client side
Answers approved by DevExpress Support
Hello,
As I understand it, you wish to modify the path of the root folder dynamically. If so, you can pass an extra parameter to your ApiController and modify the path of the PhysicalFileSystemProvider provider based on it. For example, use the RemoteFileSystemProviderBuilder.BeforeAjaxSend callback to provide a custom header for requests:
Razor(Html.DevExtreme().FileManager()
.FileSystemProvider(provider => provider.Remote()
.Url(Url.HttpRouteUrl("FileManagementScriptsApi", null)).BeforeAjaxSend(@<text>
function(arg) {
arg.headers.TestHeader = "data";
}
</text>))...
Then, access it in the controller and use it to build the path:
C#public HttpResponseMessage FileSystem() {
string path = String.Format("{0}/{1}", CurrentContext.Server.MapPath("~/Scripts"), CurrentContext.Request.Headers["TestHeader"]);
var config = new FileSystemConfiguration {
Request = new HttpContextWrapper(CurrentContext).Request,
FileSystemProvider = new PhysicalFileSystemProvider(path), ...
Let me know if this helps.
If I misunderstood your final goal, please describe it in greater detail.