从我的系统调用asp.net核心APIAngular@5.2.0应用程序和获取此信息;网络::错误“连接被拒绝”;错误
我正试图从Angular v5.2.0应用程序调用我的.net核心API函数,我得到了“GET net::ERR\u CONNECTION\u rejected zone.js:3243” 这是我用来调用api的component.js文件。 这就是我得到的错误。 您的UI(角度)代码和api是否在同一端口上运行 我可以在图中看到UI在localhost:4200上运行,您正试图在localhost:5000上调用api 确保localhost:5000已启动并正在运行,并尝试使用任何客户端(如postman)获取数据从我的系统调用asp.net核心APIAngular@5.2.0应用程序和获取此信息;网络::错误“连接被拒绝”;错误,api,asp.net-core,angular5,httprequest,Api,Asp.net Core,Angular5,Httprequest,我正试图从Angular v5.2.0应用程序调用我的.net核心API函数,我得到了“GET net::ERR\u CONNECTION\u rejected zone.js:3243” 这是我用来调用api的component.js文件。 这就是我得到的错误。 您的UI(角度)代码和api是否在同一端口上运行 我可以在图中看到UI在localhost:4200上运行,您正试图在localhost:5000上调用api 确保localhost:5000已启动并正在运行,并尝试使用任何客户端(如
import { Component, OnInit } from '@angular/core';
import { Http } from '@angular/http';
@Component({
selector: 'app-value',
templateUrl: './value.component.html',
styleUrls: ['./value.component.css']
})
export class ValueComponent implements OnInit {
values: any;
constructor(private http: Http) {
}
ngOnInit() {
this.GetValues();
}
GetValues() {
this.http.get('http://localhost:5000/api/values').subscribe(response => {
console.log(response);
});
}
}