2017-05-29 70 views
1

我的申请是ASP.NET Core 1.0 Web API。 Iam用Angular 2typescript开发前端。角度2错误:未捕获(承诺中):状态响应:0代表URL:null

如果我刷新网页之前完全加载Google Chrome一切工作正常,但如果我做同样的事情上Mozilla Firefox荫收到以下错误-消息:

[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: 
[email protected]/js/polyfills.e9e4671abf55fe5a53fc.js:57:1180 
[email protected]/js/polyfills.e9e4671abf55fe5a53fc.js:57:796 
scheduleResolveOrReject/<TheNameOfMyWebSite.net/js/polyfills.e9e4671abf55fe5a53fc.js:57:1803 
[264]/</</</o</[email protected]/js/polyfills.e9e4671abf55fe5a53fc.js:50:8316 
[email protected]/js/vendor.e9e4671abf55fe5a53fc.js:176:9452 
[264]/</</</o</[email protected]/js/polyfills.e9e4671abf55fe5a53fc.js:50:8229 
[264]/</</</n</[email protected]/js/polyfills.e9e4671abf55fe5a53fc.js:50:3362 
[email protected]/js/polyfills.e9e4671abf55fe5a53fc.js:50:367 
ZoneTask/[email protected]/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 

,但该网站刷新很好,一切工作应该如何,除了Iam收到的错误。

我只发现this后,那里的人有类似的问题。

Stackoverflow上的另一个人也有similar problem,但由于我没有使用CORS,因为前端和后端在同一个域上运行,所以这对我不起作用。

这个错误信息是什么意思?我究竟做错了什么?

回答

0

这看起来像一个CORS问题。

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.

了解更多关于它here

基本上,您的Angular2应用程序托管在另一台服务器上,而不是您要调用的API。

既然您使用的是ASP.NET Core 1.0 Web API,我建议您通读微软的Enabling Cross-Origin Requests (CORS)文档。

+0

你好@mercador谢谢你的回答。 我们没有使用CORS,因为后端和前端运行在同一个域上。 –

+1

@MoritzSchmidt也许你的Firefox浏览器安装了哪些块脚本的插件? – mercador

+0

好主意,但即使我停用所有插件Iam得到相同的错误:/ @mercador –

相关问题