Failed to load resource: the server responded with a status of 401 (Unauthorized) #1109
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
hi, i am trying to implement the server API (dotnet core 2.2)with Active Directory authentication. And on my client side, i am using Angular 8 with ng2-file-upload. I keep getting an 401 401 Unauthorized with request method: OPTIONS. I already setup the CORS on the server but still not work. Please help
Request URL: http://localhost:5000/api/client/ImportClientDemographic
Request Method: OPTIONS
Status Code: 401 Unauthorized
Remote Address: [::1]:5000
Referrer Policy: no-referrer-when-downgrade
Cache-Control: private
Content-Length: 6108
Content-Type: text/html; charset=utf-8
Date: Thu, 12 Sep 2019 20:48:49 GMT
Server: Microsoft-IIS/10.0
WWW-Authenticate: Negotiate, NTLM
X-Powered-By: ASP.NET
X-SourceFiles: =?UTF-8?B?QzpcWWFvbWluZ1xFSVNcTm9uUmVzXEVJU05vblJlcy5BcGlcYXBpXGNsaWVudFxJbXBvcnRDbGllbnREZW1vZ3JhcGhpYw==?=
Provisional headers are shown
Access-Control-Request-Method: POST
Origin: http://localhost:4200
Referer: http://localhost:4200/
Sec-Fetch-Mode: no-cors
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36
below is the error message shown on console
zone-evergreen.js:2952 OPTIONS http://localhost:5000/api/client/ImportClientDemographic 401 (Unauthorized)
scheduleTask @ zone-evergreen.js:2952
scheduleTask @ zone-evergreen.js:378
onScheduleTask @ zone-evergreen.js:272
scheduleTask @ zone-evergreen.js:372
scheduleTask @ zone-evergreen.js:211
scheduleMacroTask @ zone-evergreen.js:234
scheduleMacroTaskWithCurrentZone @ zone-evergreen.js:1107
(anonymous) @ zone-evergreen.js:2985
proto. @ zone-evergreen.js:1428
push../node_modules/ng2-file-upload/file-upload/file-uploader.class.js.FileUploader._xhrTransport @ file-uploader.class.js:302
push../node_modules/ng2-file-upload/file-upload/file-uploader.class.js.FileUploader.uploadItem @ file-uploader.class.js:105
push../node_modules/ng2-file-upload/file-upload/file-item.class.js.FileItem.upload @ file-item.class.js:30
(anonymous) @ ExcelUploadComponent.html:77
handleEvent @ core.js:43992
callWithDebugContext @ core.js:45631
debugHandleEvent @ core.js:45246
dispatchEvent @ core.js:29803
(anonymous) @ core.js:42924
(anonymous) @ platform-browser.js:2668
invokeTask @ zone-evergreen.js:391
onInvokeTask @ core.js:39679
invokeTask @ zone-evergreen.js:390
runTask @ zone-evergreen.js:168
invokeTask @ zone-evergreen.js:465
invokeTask @ zone-evergreen.js:1603
globalZoneAwareCallback @ zone-evergreen.js:1629
localhost/:1 Access to XMLHttpRequest at 'http://localhost:5000/api/client/ImportClientDemographic' from origin 'http://localhost:4200' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Hi,
It really looks like a CORS issue. Please, check if you are correctly setting the
Access-Control-Allow-Originheader.If it is, please give us details about the OPTIONS call response (headers and body).
localhost:5000/api/gList/?zone.js:2863 =user::3 401 (Unauthorized)