Ticket T1105136
Visible to All Users

FileManager for ASP.NET Core - How to pass arguments to Web API part from client side

created 3 years ago

Hello, how could I pass arguments in it so that the path of the PhysicalFileSystemProvider is dynamic?

Answers approved by DevExpress Support

created 3 years ago

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.

    Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

    Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.