Click here to Skip to main content
15,847,077 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i work on web page web api and angular 11

this page take input file excel and get result on excel file as output

i get error i don't know what is the reason of error and how to solve it

error as below

Access to XMLHttpRequest at '' from origin '' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
 Failed to load resource: net::ERR_FAILED
main.f13cbf3….js:1 ERROR 
e {headers: n, status: 0, statusText: 'Unknown Error', url: '', ok: false, …}
error: ProgressEvent {isTrusted: true, lengthComputable: false, loaded: 0, total: 0, type: 'error', …}
headers: n {normalizedNames: Map(0), lazyUpdate: null, headers: Map(0)}
message: "Http failure response for 0 Unknown Error"
name: "HttpErrorResponse"
ok: false
status: 0
statusText: "Unknown Error"
url: ""
[[Prototype]]: Object

so please can any one help me please ?

What I have tried:

web api
        public IActionResult ExportNxp(bool areIdentical)
                if (areIdentical == false)
                    return OK("Not Matched Excel");
                return PhysicalFile(zipPath, "application/zip", Path.GetFileName(zipPath));

  formData.append('file', file,;
  return'', formData,{observe: 'response', responseType: 'blob' });
     .subscribe(blob => {
       saveAs(blob.body, this.fileToUpload?.name +'.zip');

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900