2016-08-13 2 views
0

私は角2Angular2とナンシー:処理エラーメッセージ

マイナンシー・サーバ・コードに基づいてWebアプリケーションにナンシー・エラー・メッセージから復帰しよう:クライアント側で

private dynamic GetSolution(dynamic arg) 
    { 
     string solutionName = arg.name; 

     if (solutionName == "error") 
     { 
      var response = Json(new {message = $"error"}); 
      response.StatusCode = HttpStatusCode.BadRequest; 
      return response; 
     } 

     return Json(solutionService.GetSolutionByName(solutionName)); 
    } 

次とプロセス応答コード:

onButtonClicked(name: string): void 
{ 
    this 
     .solutionsService 
     .getSolutionByName(name) 
     .subscribe(
      p=>this.showMessage(p.title), 
      p=>this.showError(p.message)); 
    //this.refresh(true); 
} 

ステータス200とREPONSE場合 - 私はenter image description here

、予想されるオブジェクト(フィールドIDとタイトルとの溶液)を受信します

が、ステータスコード0エラー(例えば400)場合、私は予想外のオブジェクトを取得する: enter image description here

私が間違って何?

答えて

0

CORS問題にエラーがありました。成功レスポンスでは私はCORSヘッダーをレスポンスに追加しましたが、無効なレスポンスでは私はそれをしませんでした。なぜOPTIONSの飛行前要求からの返信が返されたのか?

関連する問題