2016-08-02 3 views
1

私は504を返す私のApiControllerへの呼び出しがあり、私は間違っていることを解決できません...ApiController returned 504 - サーバーはこの要求に対して完全な応答を返しませんでした。サーバは0バイトを返しました

誰か問題が発生しますか?

これはコントローラです:

public class SA_GetAllLocationsController : ApiController 
{ 
    [Route("SA_GetAllLocations")] 
    [HttpGet] 
    public List<SA_Locations> Get() 
    { 
     List<SA_Locations> result = SADatastore.Functions.Location.GetAllLocations(Settings.Default.ConnectionString); 

     return result; 
    } 
} 

これが最初のEntity Frameworkのデータベースによって生成されたクラスSA_Locationsです...

public partial class SA_Locations 
{ 
    public SA_Locations() 
    { 
     this.SA_Items = new HashSet<SA_Items>(); 
    } 

    public string LocationID { get; set; } 
    public string BuildingID { get; set; } 
    public string Name { get; set; } 
    public string Description { get; set; } 
    public string MISID { get; set; } 
    public string GPSCoords { get; set; } 
    public string QRCode { get; set; } 
    public Nullable<bool> Signable { get; set; } 
    public Nullable<bool> Auditable { get; set; } 
    public Nullable<bool> Bookable { get; set; } 
    public Nullable<bool> Entrance { get; set; } 
    public Nullable<bool> Exit { get; set; } 
    public Nullable<bool> Active { get; set; } 
    public System.DateTime LastUpdated { get; set; } 

    public virtual SA_Buildings SA_Buildings { get; set; } 
    public virtual ICollection<SA_Items> SA_Items { get; set; } 
} 

私が働く小さな「ステータス」機能を書かれています完璧で、このように見えます:

public HttpResponseMessage Get() 
    { 
     return new HttpResponseMessage() 
     { 
      Content = new StringContent(
       "SA service is running and ready to accept connections!", 
       Encoding.UTF8, 
       "text/html" 
      ) 
     }; 
    } 

私はちょうどSA_Locデバッグ時にエラーなしで返されているようですが、Fiddlerに表示されるレスポンスは次のとおりです。

504 - サーバーはこの要求に対して完全な応答を返しませんでした。サーバーは0バイトを返しました

オブジェクトが返されるのは複雑すぎますか?

ご協力いただければ幸いです。

TREV

私が試してみて、私は次のようコントローラを再書いたように、私は、コントローラからの純粋なJSONを返す場合は何が起こるかを見ることにしました

UPDATE:

public class SA_GetAllLocationsController : ApiController 
{ 
    [Route("SA_GetAllLocations")] 
    [HttpGet] 
    public HttpResponseMessage Get() 
    { 
     List<SA_Locations> result = SADatastore.Functions.Location.GetAllLocations(Settings.Default.ConnectionString); 

     string output = JsonConvert.SerializeObject(result); 

     return new HttpResponseMessage() 
     { 
      Content = new StringContent(
       output, 
       Encoding.UTF8, 
       "application/json" 
      ) 
     }; 
    } 
} 

SA_Locationsオブジェクトを文字列にシリアライズするエラーを実際にスローします。

エラーメッセージは次のとおりです。

タイプの例外「Newtonsoft.Json.JsonSerializationExceptionは」Newtonsoft.Json.dllで発生したが、ユーザーコードで

追加情報は処理されませんでした:エラーの取得値を「SA_Buildings」から「System.Data.Entity.DynamicProxies.SA_Locations_720FF8784B152496318F87BCB674E344B97C0446B16D4DC2BDDC381D88C048B9」を選択します。だから、

、それは、私が言ったようにSA_Locations、と何かに向かって指してん....

は近いが、なぜそのオブジェクトが「勝っていないアイデア最初のEntity Frameworkのデータベースによって生成されたクラスの取得されますシリアル化?

答えて

関連する問題