Does not work in asp.net core mvc hosted in window service.

I'm using .net core 3.1 MVC project and syncfusion version 19.1.0.64
All code is from demo and
log error is shown as 
Connection id ""0HM92MOE5OS8Q"", Request id ""0HM92MOE5OS8Q:00000007"": An unhandled exception was thrown by the application.
System.ArgumentOutOfRangeException: startIndex cannot be larger than length of string. (Parameter 'startIndex')
   at System.String.Substring(Int32 startIndex, Int32 length)
   at System.String.Substring(Int32 startIndex)
   at Syncfusion.EJ2.FileManager.PhysicalFileProvider.PhysicalFileProvider.GetRelativePath(String rootPath, String fullPath)
   at Syncfusion.EJ2.FileManager.PhysicalFileProvider.PhysicalFileProvider.<>c__DisplayClass13_0.<ReadDirectories>b__1(DirectoryInfo subDirectory)
   at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
   at System.Linq.Enumerable.ConcatIterator`1.MoveNext()
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList(JsonWriter writer, IEnumerable values, JsonArrayContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerProperty)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerProperty)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)
   at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType)
   at Newtonsoft.Json.JsonConvert.SerializeObjectInternal(Object value, Type type, JsonSerializer jsonSerializer)
   at Newtonsoft.Json.JsonConvert.SerializeObject(Object value, JsonSerializerSettings settings)
   at Syncfusion.EJ2.FileManager.PhysicalFileProvider.PhysicalFileProvider.ToCamelCase(FileManagerResponse userData)
   at MonkeyApp.Controllers.FileManagerController.FileOperations(FileManagerDirectoryContent args) in D:\Dot Net\MonkeyApp\MonkeyApp\Controllers\FileManagerController.cs:line 58
   at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)

6 Replies 1 reply marked as answer

IL Indhumathy Loganathan Syncfusion Team May 31, 2021 01:38 PM UTC

Hi Angus, 
  
Greetings from Syncfusion support. 
  
We have validated your reported query in File Manager component. To validate the reported issue, we have prepared a MVC sample in 19.1.64 package version and hosted it in IIS. But, unable to replicate the issue you are facing in File Manager control. Please find the sample from below link. 
 
  
We understood that you have been facing some issue in File Manager component, but in order to replicate the issue in our end we need some additional details. 
  
1.      Whether you are facing this issue on initial rendering or while performing any file operation? 
2.      Whether this issue only occurs while hosting the sample? 
3.      Steps followed in your end to host your application. 
4.      File Manager related code snippets and video footage of issue. 
5.      If possible, share us a live hosted link or reproduce the issue in the above shared sample. 
  
These details will help us to serve you better. 
  
Regards, 
Indhumathy L

Marked as answer

AC angus chao June 1, 2021 12:38 AM UTC

Thanks for your reply.
http://61.70.247.8/FileManager/Index
(user : yoex)
Above is my live host in window serivce(testing environment and will be available one week). And also attach with file manager controller.
It works well in IIS or Kestrel console but not in window service.
I'm just make standalone web application without IIS that can be hosted in window service or run like normal program.

Attachment: FileManagerController_92f7a65a.zip


AC angus chao replied to angus chao June 1, 2021 03:47 AM UTC

Thanks for your reply.
http://61.70.247.8/FileManager/Index
(user : yoex)
Above is my live host in window serivce(testing environment and will be available one week). And also attach with file manager controller.
It works well in IIS or Kestrel console but not in window service.
I'm just make standalone web application without IIS that can be hosted in window service or run like normal program.

Attachment: FileManagerController_92f7a65a.zip

I found something that work. Because my project folder was put in D directory and it can not accessible by window service or something (I don't know). But I put my project folder in my document folder, it works fine.
Thanks for your patience and I think I must find some way to work around with window service host.


AC angus chao June 1, 2021 04:29 AM UTC

finally solve the problem. It was all about path and in documentation 
this.operation.RootFolder(this.basePath + "\\" + this.root);
I've change above line to 
this.operation.RootFolder(Path.Combine(this.basePath, this.root));
Thanks you very much.


KR Keerthana Rajendran Syncfusion Team June 1, 2021 05:24 AM UTC

Hi Angus, 
 
Most welcome. We are glad to know that the issue has been resolved in your end. Please get back to us if you need further assistance. We will be happy to assist you. 
 
Regards, 
Keerthana. 



Médoune replied to angus chao April 27, 2023 12:16 AM UTC

Thank you very much, I have spend couple of hours on debugging, you save my life


Loader.
Up arrow icon