2016-12-20 17 views
0

このファイルをオンデマンドに保存すると「非常に長い」Json文字列を出力しようとしていますが、これは405KBですが、レスポンスでクライアントに提供したいのですが。書き込みはしますが、何らかの理由で出力されず、文字列が埋められます。 私はそれが私の画面に応答を入れていないだろうc#Response.Write and End()Json String to long

// Clear out the buffer 
    Response.ClearHeaders(); 
    Response.ClearContent(); 
    Response.Clear(); 

    // Do not cache response 
    Response.Cache.SetCacheability(HttpCacheability.NoCache); 

    // Set the content type and encoding for JSON 
    Response.ContentType = "application/json"; 
    Response.ContentEncoding = Encoding.UTF8; 
    Response.Write(strJsonData); 

    // Flush the response buffer 
    Response.Flush(); 

    // Complete the request. NOTE: Do not use Response.End() here, 
    // because it throws a ThreadAbortException, which cannot be caught! 
    HttpContext.Current.ApplicationInstance.CompleteRequest(); 

を使用する場合には、MVC シンプルなASP.NET Webページではありません。 のWeb.config

<httpRuntime maxRequestLength ="999999999" requestValidationMode="2.0" /> 

<system.webServer> 
    <security> 
     <requestFiltering> 
      <requestLimits maxAllowedContentLength="999999999" /> 
     </requestFiltering> 
    </security> 
</system.webServer> 
+0

エラーメッセージは何ですか? 'Response.Write'は発信について、' requestLimits'は着信データについてです。 – fubo

+0

'ondisk'とは何を意味していますか?文字列をサーバーに保存したいと思っていますか?それとも、実際にJsonの結果をクライアントに送信することを意味していますか? –

+0

私はそれを私がそれをonwriteディスク405kbを保存するときにファイル自体がResponse.Writeでクライアントに応答したいと思うことを意味します。しかし、それは動作しませんが、JsonResultは満たされています。 –

答えて

1

要求の長さがサーバーではなく、レスポンスに行くの長さの要求を制限します。私が試した何

は、Web.configファイルでこれを試してみてください:

<configuration> 
 
    <system.web.extensions> 
 
     <scripting> 
 
      <webServices> 
 
       <jsonSerialization maxJsonLength="99999999"/> 
 
      </webServices> 
 
     </scripting> 
 
    </system.web.extensions> 
 
</configuration>

+0

イムつもりは –

+0

恐ろしいそれを試してみてください!!!! Ty Dirk Maesが働いています! –

+0

実際に役立つ情報です! –