此消息由firefox生成 .

跨源请求已阻止:同源策略不允许在http://localhost:56647/api/Events读取远程资源 . (原因:CORS预检 Channels 没有成功) .

<httpProtocol>
  <customHeaders>
    <add name="Access-Control-Allow-Origin" value="*" />
    <add name="Access-Control-Allow-Headers" value="Content-Type" />
    <add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS" />
  </customHeader>

角质服务

addEvent(event:Event): Observable<Event> {
let headers = new Headers({'Content-Type':'application/son'});
return this.http.post('http://localhost:56647/api/Events', 
JSON.stringify(event), { headers: headers })
    .map((res: Response) => res.json());
 }

POST CALL

addEvent( title : string ,postcode : string ,description :  string){
   this.newEvent =  new Eventos(title, postcode, description, postcode, 
    description);
    console.log(this.newEvent);
    this.eventService.addEvent(this.newEvent).subscribe((newEvent) =>{
  this.newEvent = newEvent;
},
(error) => {
  this.statusMessage = 'Problem with the service';
  console.log(error);
});

我已经在Web应用程序配置文件中启用了全局以下代码 . 然而,当做post post时,帖子没有到达web api应用程序 . 谢谢