We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Chunk upload only first time run into Save function when the WebAPI disabled anonymous identity

Hi 

I am using the upload control, and fount some errors and I don't know how to fix it.

I am using chunk upload


add authorization before uploading, for runing into my api successfully.


The first time, it run into the save method, and I found the headers length is 14, contains "Authorization"


but the second time run the method , the headers length is 13 ? And when my WebAPI  disable anonymous identity, the second time doesn't run into the save mthod, only the first time run into save method. It seems lost the "Authorization"


and the error is unauthorized.




8 Replies

LO lorryl December 6, 2018 08:29 AM UTC

Also, I cannot get the additional data for sencond times and other times when using chunk upload.

HttpContext.Current.Request.Form["userName"]




CI Christopher Issac Sunder K Syncfusion Team December 7, 2018 06:42 AM UTC

Hi lorryl, 

Thank you for contacting Syncfusion support. 

We have validated your query in uploader component. We have already considered this was an improvement in file upload. So, the implementation changes for this improvement in the uploader component will be included in Volume 4 2018 release which is expected to be rolled out in the mid of this month (December, 2018). 
 
We appreciate your patience until then. 

Thanks,
Christo



LO lorryl December 7, 2018 06:57 AM UTC

Thanks for your reply.

The reason that I need to disable anonymous identity, is I want to get the current windows user name, and I search in goole,  set windows authentication in my WebAPI of IIS, but I still cannot get the correct windows user name in website. Do you have any idear ?


PO Prince Oliver Syncfusion Team December 11, 2018 09:33 AM UTC

Hi Lorryl, 

Thank you for your update. 

You can use the below code snippet to get the currently logged-in windows username in controller page. 
 
System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString();  
 
If the above provided solution does not meet your requirement, please get back to us with more information on requirement with example code or sample. It will help us provide solution at the earliest.  

Regards, 
Prince 



LO lorryl June 5, 2019 12:36 PM UTC

Hi,

I set the webAPI in the computer 1, eg: hk-techser8, and set the web in the computer 2, eg: tecweb2, when I use to upload file on the web, file saved failed.
I don't know how to fix it, please help me.

If the webapi and the web are in one computer, it will be no problem.



The web.config of webapi:


It seems the OPTIONS is blocked , I don't know why ? The path save url is options request ?



PO Prince Oliver Syncfusion Team June 6, 2019 09:20 AM UTC

Hello Lorryl, 

Good day to you. 

This is a CORS issue. To resolve this, you need to allow access to the WebAPI method from all other sources in the webconfig file. Kindly refer to the following code 
 
<configuration>  
  <system.webServer>  
    <httpProtocol>  
      <customHeaders>  
        <add name="Access-Control-Allow-Origin" value="*" />  
      </customHeaders>  
    </httpProtocol>  
  </system.webServer>  
</configuration>  

In your end, you have enabled access only for the http://hk-techserver8. Let us know if you need any further assistance on this. 

Regards, 
Prince 



LO lorryl replied to Christopher Issac Sunder K June 10, 2019 08:19 AM UTC

Hi lorryl, 

Thank you for contacting Syncfusion support. 

We have validated your query in uploader component. We have already considered this was an improvement in file upload. So, the implementation changes for this improvement in the uploader component will be included in Volume 4 2018 release which is expected to be rolled out in the mid of this month (December, 2018). 
 
We appreciate your patience until then. 

Thanks,
Christo


Chunk upload only first time run into Save function when the WebAPI is windows authorization.
You didnot fix the problem, please see it.


PO Prince Oliver Syncfusion Team June 11, 2019 09:11 AM UTC

Hello Lorryl, 

Good day to you. 

We have checked your reported scenario. You have used the uploading event to add additional headers in the chunk uploader and hence you are facing this issue. We have provided chunkUploading event which fires for every chunk upload process gets started. To add the additional parameter with the current request, we suggest you add the headers in the chunkUploading event. Please refer the below code snippet. 

[html] 
<ejs-uploader #chunkupload id='chunkfileupload' [maxFileSize]=104857600 [autoUpload]=false [asyncSettings]='path' [dropArea]='dropElement' (pausing)='onPausing($event)' (resuming)='onResuming($event)' (removing)='onFileRemove($event)'(chunkFailure)='onBeforefailure($event)' (chunkUploading)='onChunkuploading($event)'> </ejs-uploader> 


[ts] 
public onChunkuploading(args: any): void { 
  if (args.currentRequest) { 
    args.currentRequest.withCredenials = true; 
  } 
} 

Please check the above solution in your end and let us know if you need any further assistance on this. 

Regards, 
Prince 


Loader.
Up arrow icon