1

My application is an ASP.NET Core 1.0 Web API. Iam developing the frontend with Angular 2 and typescript.

If I refresh the website before it completely loaded in Google Chrome everything works fine but, if I do the same thing on Mozilla Firefox Iam getting the following Error-Message:

[error.service] An error occured: Object { _body: error, status: 0, ok: false, statusText: "", headers: Object, type: 3, url: null }  app.e9e4671abf55fe5a53fc.js:936:46167

s</ConsoleLogger.prototype.error TheNameOfMyWebSite.net/js/app.e9e4671abf55fe5a53fc.js:936:46167
u</ErrorService.prototype.handleError TheNameOfMyWebSite.net/js/app.e9e4671abf55fe5a53fc.js:936:39646
u</CustomHttp.prototype.request/< TheNameOfMyWebSite.net/js/app.e9e4671abf55fe5a53fc.js:936:38047
a</CatchSubscriber.prototype.error TheNameOfMyWebSite.net/js/vendor.e9e4671abf55fe5a53fc.js:543:27790
a TheNameOfMyWebSite.js:311:808
[264]/</</</o</ZoneDelegate.prototype.invokeTask TheNameOfMyWebSite.net/js/polyfills.e9e4671abf55fe5a53fc.js:50:8316
onInvokeTask TheNameOfMyWebSite.js:176:9452
[264]/</</</o</ZoneDelegate.prototype.invokeTask TheNameOfMyWebSite.net/js/polyfills.e9e4671abf55fe5a53fc.js:50:8229
[264]/</</</n</Zone.prototype.runTask TheNameOfMyWebSite.net/js/polyfills.e9e4671abf55fe5a53fc.js:50:3362
ZoneTask/this.invoke TheNameOfMyWebSite.net/js/polyfills.e9e4671abf55fe5a53fc.js:50:9349


ERROR Error: Uncaught (in promise): Response with status: 0  for URL: null
Stack-Trace:
resolvePromise@TheNameOfMyWebSite.net/js/polyfills.e9e4671abf55fe5a53fc.js:57:1180
resolvePromise@TheNameOfMyWebSite.net/js/polyfills.e9e4671abf55fe5a53fc.js:57:796
scheduleResolveOrReject/<TheNameOfMyWebSite.net/js/polyfills.e9e4671abf55fe5a53fc.js:57:1803
[264]/</</</o</ZoneDelegate.prototype.invokeTask@TheNameOfMyWebSite.net/js/polyfills.e9e4671abf55fe5a53fc.js:50:8316
onInvokeTask@TheNameOfMyWebSite.net/js/vendor.e9e4671abf55fe5a53fc.js:176:9452
[264]/</</</o</ZoneDelegate.prototype.invokeTask@TheNameOfMyWebSite.net/js/polyfills.e9e4671abf55fe5a53fc.js:50:8229
[264]/</</</n</Zone.prototype.runTask@TheNameOfMyWebSite.net/js/polyfills.e9e4671abf55fe5a53fc.js:50:3362
drainMicroTaskQueue@TheNameOfMyWebSite.net/js/polyfills.e9e4671abf55fe5a53fc.js:50:367
ZoneTask/this.invoke@TheNameOfMyWebSite.net/js/polyfills.e9e4671abf55fe5a53fc.js:50:9396

defaultErrorLogger TheNameOfMyWebSite.net/js/vendor.e9e4671abf55fe5a53fc.js:8:473
ee</ErrorHandler.prototype.handleError TheNameOfMyWebSite.net/js/vendor.e9e4671abf55fe5a53fc.js:162:273
next TheNameOfMyWebSite.net/js/vendor.e9e4671abf55fe5a53fc.js:176:14602
Qe</EventEmitter.prototype.subscribe/i< TheNameOfMyWebSite.net/js/vendor.e9e4671abf55fe5a53fc.js:176:6258
c</SafeSubscriber.prototype.__tryOrUnsub TheNameOfMyWebSite.net/js/vendor.e9e4671abf55fe5a53fc.js:211:3724
c</SafeSubscriber.prototype.next TheNameOfMyWebSite.net/js/vendor.e9e4671abf55fe5a53fc.js:211:2960
u</Subscriber.prototype._next TheNameOfMyWebSite.net/js/vendor.e9e4671abf55fe5a53fc.js:211:1927
u</Subscriber.prototype.nextTheNameOfMyWebSite.net/js/vendor.e9e4671abf55fe5a53fc.js:211:1574
p</Subject.prototype.next TheNameOfMyWebSite.net/js/vendor.e9e4671abf55fe5a53fc.js:211:6849
Qe</EventEmitter.prototype.emit TheNameOfMyWebSite.net/js/vendor.e9e4671abf55fe5a53fc.js:176:6006
Xe</NgZone.prototype.triggerError TheNameOfMyWebSite.net/js/vendor.e9e4671abf55fe5a53fc.js:176:10237
onHandleError TheNameOfMyWebSite.net/js/vendor.e9e4671abf55fe5a53fc.js:176:9812
[264]/</</</o</ZoneDelegate.prototype.handleError TheNameOfMyWebSite.net/js/polyfills.e9e4671abf55fe5a53fc.js:50:7683
[264]/</</</n</Zone.prototype.runGuarded TheNameOfMyWebSite.net/js/polyfills.e9e4671abf55fe5a53fc.js:50:2951
[264]/</</</n.microtaskDrainDone/< TheNameOfMyWebSite.net/js/polyfills.e9e4671abf55fe5a53fc.js:57:2461
[264]/</</</n.microtaskDrainDone TheNameOfMyWebSite.net/js/polyfills.e9e4671abf55fe5a53fc.js:57:2430
drainMicroTaskQueue TheNameOfMyWebSite.net/js/polyfills.e9e4671abf55fe5a53fc.js:50:477
ZoneTask/this.invoke TheNameOfMyWebSite.net/js/polyfills.e9e4671abf55fe5a53fc.js:50:9396 

But the website refreshes fine and everything works how it should, except for the error Iam receiving.

I only found this post, where the person had a similar problem.

Another person on Stackoverflow also had a similar problem, but since I am not using CORS because frontend and backend run on the same domain, this won't work for me.

What does this error message mean? What am I doing wrong?

Moritz Schmidt
  • 2,635
  • 3
  • 27
  • 51

1 Answers1

-1

This looks like a CORS issue.

Cross-origin resource sharing (CORS) is a mechanism that allows restricted resources (e.g. fonts) on a web page to be requested from another domain outside the domain from which the first resource was served.

Read more about it here.

Basically your Angular2 application is hosted on another server than the API you are calling.

Since you are using ASP.NET Core 1.0 Web API, I suggest you read through the Microsoft's Enabling Cross-Origin Requests (CORS) documentation.

mercador
  • 272
  • 6
  • 11