2016-12-23 4 views
0

マイAPIコントローラがどのように見える空のデータを返します。APIから

[System.Web.Http.HttpGet] 
[System.Web.Http.HttpPost] 
public DataTable Get() 
{ 
    DataTable t = new DataTable("t"); 
    using (SqlDataAdapter adapter = new SqlDataAdapter(cmd)) 
    {      
    adapter.Fill(t);     
    } 
    return t; 
} 

そして、私の角度のAPIサービスリクエストデータ:

// contoller 
$scope.getReport = function() { 
     apiService.post('/api/test/get', null, 
     getReportLoadCompleted, 
     getReportLoadFailed); 
} 

function getReportLoadCompleted(result) { 
     $scope.report = result.data; 
} 

// api service 
function post(url, data, success, failure) { 
     return $http.post(url, data) 
       .then(function (result) { 
        success(result); 
       }, function (error) { 
        if (error.status == '401') { 

         $rootScope.previousState = $location.path(); 
         $location.path('/login'); 
        } 
        else if (failure != null) { 
         failure(error); 
        } 
       }); 
    } 

APIリターン60列内のデータと200.000行、it'ok、失敗なし、result.dataは200.000行の配列です。 しかし、apiが60列と250.000行のデータを返す場合、それは正常ですが、 result.dataは空の文字列です。

何が問題ですか? これについてお考えですか?

+0

WebApiにはDataTableのデフォルトシリアライザがありません。ここをご覧くださいhttp://stackoverflow.com/questions/14571927/net-webapi-datatable – Fals

答えて

0

エンドポイントapp.configを設定する必要があります。例えば;

<bindings> 
    <basicHttpBinding> 
     <binding name="basicHttp" allowCookies="true" 
       maxReceivedMessageSize="20000000" 
       maxBufferSize="20000000" 
       maxBufferPoolSize="20000000"> 
      <readerQuotas maxDepth="32" 
       maxArrayLength="200000000" 
       maxStringContentLength="200000000"/> 
     </binding> 
    </basicHttpBinding> 
</bindings> 
関連する問題