Azure File Provider 404 on Core, 403 on MVC

We've been using your file manager for approximately a year now after getting it deployed correctly. We currently had an issue where the user was unable to download a file when specified but​ the files can be downloaded by selecting the directory the file is stored in and then selecting download. We are currently still using the file provider examples listed on Github but found different errors when using either the ASP.NET Core and MVC versions which we're not sure how to debug. I separated out the inline call to download the file in order to find out what was causing the issue and found the following


MVC - 403 Forbidden - AzureFileProvider.cs line 460

The remote server returned an error: (403) Forbidden.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.WebException: The remote server returned an error: (403) Forbidden.

Source Error:

Line 470:                    string uri = FilesPath + "emg/" + (names[0].Contains('/') ? "/" : selectedItems[0].FilterPath)
Line 471:                        + names[0] + "?sv=2019-10-10&ss=bf&srt=o&sp=rx&se=2021-06-01T17:47:22Z&st=2020-06-03T09:47:22Z&spr=https,http&sig=ynsv325R2Az2lqPvgS7m60OD%2BXzbI6h2qlVVsTw%2FBjk%3D";
Line 472:                    byte[] client = new WebClient().DownloadData(uri);
Line 473:                    MemoryStream mem = new MemoryStream(client);
Line 474:                    FileStreamResult fileStreamResult = new FileStreamResult(mem, "APPLICATION/octet-stream");

Source File: C:\Users\adam\Documents\GitHub\ej2-azure-aspmvc-file-provider\Models\AzureFileProvider.cs    Line: 472

Stack Trace:

[WebException: The remote server returned an error: (403) Forbidden.]
   System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request) +298
   System.Net.WebClient.DownloadData(Uri address) +106
   System.Net.WebClient.DownloadData(String address) +32
   Syncfusion.EJ2.FileManager.AzureFileProvider.<DownloadAsync>d__30.MoveNext() in C:\Users\adam\Documents\GitHub\ej2-azure-aspmvc-file-provider\Models\AzureFileProvider.cs:472
   System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +102
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +64
   System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() +29
   Syncfusion.EJ2.FileManager.AzureFileProvider.AzureFileProvider.Download(String path, String[] names, FileManagerDirectoryContent[] selectedItems) in C:\Users\adam\Documents\GitHub\ej2-azure-aspmvc-file-provider\Models\AzureFileProvider.cs:460
   EJ2AzureASPMVCFileProvider.Controllers.AzureProviderController.AzureDownload(String downloadInput) in C:\Users\adam\Documents\GitHub\ej2-azure-aspmvc-file-provider\Controllers\AzureProviderController.cs:92
   lambda_method(Closure , ControllerBase , Object[] ) +103
   System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +14
   System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +157
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
   System.Web.Mvc.Async.<>c.<BeginInvokeSynchronousActionMethod>b__9_0(IAsyncResult asyncResult, ActionInvocation innerInvokeState) +22
   System.Web.Mvc.Async.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult) +29
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +32
   System.Web.Mvc.Async.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__11_0() +50
   System.Web.Mvc.Async.<>c__DisplayClass11_1.<InvokeActionMethodFilterAsynchronouslyRecursive>b__2() +228
   System.Web.Mvc.Async.<>c__DisplayClass7_0.<BeginInvokeActionMethodWithFilters>b__1(IAsyncResult asyncResult) +10
   System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +34
   System.Web.Mvc.Async.<>c__DisplayClass3_6.<BeginInvokeAction>b__3() +35
   System.Web.Mvc.Async.<>c__DisplayClass3_1.<BeginInvokeAction>b__5(IAsyncResult asyncResult) +100
   System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +27
   System.Web.Mvc.<>c.<BeginExecuteCore>b__152_1(IAsyncResult asyncResult, ExecuteCoreState innerState) +11
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +45
   System.Web.Mvc.<>c.<BeginExecute>b__151_2(IAsyncResult asyncResult, Controller controller) +13
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +22
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +26
   System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
   System.Web.Mvc.<>c.<BeginProcessRequest>b__20_1(IAsyncResult asyncResult, ProcessRequestState innerState) +28
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +28
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9850009
   System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +50
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +163

Core - 404 Not Found - AzureFileProvider.cs line 568 An unhandled exception occurred while processing the request.

WebException: The remote server returned an error: (404) The specified resource does not exist..

System.Net.HttpWebRequest.GetResponse()

  • Stack 
  • Query 
  • Cookies 
  • Headers
  • WebException: The remote server returned an error: (404) The specified resource does not exist..

    • System.Net.HttpWebRequest.GetResponse()

    • System.Net.WebClient.GetWebResponse(WebRequest request)

    • System.Net.WebClient.DownloadBits(WebRequest request, Stream writeStream)

    • System.Net.WebClient.DownloadDataInternal(Uri address, out WebRequest request)

    • System.Net.WebClient.DownloadData(Uri address)

    • System.Net.WebClient.DownloadData(string address)

    • Syncfusion.EJ2.FileManager.AzureFileProvider.AzureFileProvider.DownloadAsync(string path, string[] names, FileManagerDirectoryContent[] selectedItems) in AzureFileProvider.cs

      1. byte[] data = new WebClient().DownloadData(azurePath);
    • Syncfusion.EJ2.FileManager.AzureFileProvider.AzureFileProvider.Download(string path, string[] names, FileManagerDirectoryContent[] selectedItems) in AzureFileProvider.cs

      1. return DownloadAsync(this.filesPath + path + "", names, selectedItems).GetAwaiter().GetResult();
    • EJ2AzureASPCoreFileProvider.Controllers.AzureProviderController.AzureDownload(string downloadInput) in AzureProviderController.cs

      1. return operation.Download("emg" + args.Path, args.Names, args.Data);
    • Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(object target, object[] parameters)

    • Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor+SyncObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, object controller, object[] arguments)

    • Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()

    • Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()

    • Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)

    • Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)

    • Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()

    • Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()

    • Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)

    • Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)

    • Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()

    • Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()

    • Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)

    • Microsoft.AspNetCore.Cors.Infrastructure.CorsMiddleware.Invoke(HttpContext context)

    • Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)


Any assistance would be extremely helpful as this is a live product that is currently being used and we have informed our client of the work around of downloading the directory. The only issue with that being that the full path is downloaded plus all other resour

3 Replies

IL Indhumathy Loganathan Syncfusion Team August 23, 2021 12:28 PM UTC

Hi Adam, 
 
Greetings from Syncfusion support. 
 
We have validated your reported query in File Manager component. We have used both Core and MVC Azure Service Providers and used the IIS hosted link of providers in Vue sample. We have performed download operation for both files and folders but unable to replicate the reported issue. We recorded the same in the below video footage. 
 
 
Kindly confirm whether you are using the below service providers. 
 
 
 
Since we are unable to replicate the issue in our end, we need below details to further validate on this issue. 
 
1.      Whether you have performed any customizations in your service providers? 
2.      Steps you followed to host the service provider. 
3.      Whether you are facing this issue in local service also. 
4.      Whether you are facing this issue only on download operation or other operations as well. 
 
These details would help us to assist you promptly. We also suspect that the issue may occur due to the mapped Azure path doesn’t exist. So, we suggest you to check the below general blogs to resolve the issue. 
 
 
 
Please let us know if you need any further assistance. 
 
Regards, 
Indhumathy L  



AR Adam Ratcliffe August 26, 2021 11:11 AM UTC

  1. Whether you have performed any customizations in your service providers? 

Aside from replacing the information to connect to the Azure storage we do have a different web.config file

  1. Steps you followed to host the service provider. 

We deployed the project as an Azure Web Application

3.      Whether you are facing this issue in local service also.

No, this only seems to be a hosted issue. We have been able to download any file on the Azure blob storage from my local machine which should be using the same configuration as the hosted one.

4.      Whether you are facing this issue only on download operation or other operations as well.

This issue only seems to persist on the download functionality and doesn’t affect downloading a directory. We are able to rename, upload and create files on the server but then cannot download them.



We do not feel confident in sending some of the information such as the web.config or the method we deploy the Azure web app since this is on a publicly available forum and we could potentially share sensitive information which we do not want to be accessed such as the license key in the web.config




IL Indhumathy Loganathan Syncfusion Team August 27, 2021 01:13 PM UTC

Hi Adam, 
 
Based on the shared details, we are unable to replicate the exact issue you have been facing. In our demo samples, we have hosted the File Provider in Azure and mapped them in File Manager. We were able to perform Download operation for files as well. Check out the below link. 
 
 
The reported issue may occur with the below two cases, so we suggest you to ensure this in your end. 
 
Case 1: Check whether you have enabled access permissions for the files in Azure blob storage. Refer to the below blog for more details. 
 
 
Case 2: Check whether you have mapped the proper path details in Azure controller. 
 
You need to specify the startPath and originalPath values as below.  
  
string originalPath = ("https://azure_service_account.blob.core.windows.net/files/Files").Replace(startPath, "");  
  
In the above links, Files is the container name which includes the directory files in Azure blob storage. The reported issue occur when you mention the originalPath as shown below,  
  
string originalPath = ("https://azure_service_account.blob.core.windows.net/files/Files/").Replace(startPath, "");  
  
The extra / at the end of the path prevents the sub-folders and sub-files selection. This maybe the reason for the 404 error at your end. 
 
Kindly check this in your end. If the issue persists, we need details on your service provider code. We can understand that you can’t share sensitive information in public forum, please share the information to [email protected], which will be confidential. 
 
Please let us know if you need any further assistance. 
 
Regards, 
Indhumathy L 


Loader.
Up arrow icon