2013-10-19 2 views
1

IIS 7.5 웹 서버에서 gzip을 올바르게 설정하면 대부분의 경우 작동합니다.json을 ASP.NET MVC의 JsonResult 액션에서 반환하는 방법은 무엇입니까?

그러나 응답 헤더에서 JsonResult 메소드에 대한 요청이 gzipped되지 않았 음을 알 수 있습니다. JsonResult가 Content-Encoding : gzip으로 데이터를 반환하도록 변경하려면 무엇이 필요합니까?

enter image description here

: 반환 뭔가를 HTML, 예를 들어 RenderPartial()를 호출 헤더의 스크린 샷에

enter image description here

을 비교하십시오 JsonResult 메서드를 호출 할 때

헤더의 스크린 샷입니다

편집 :이 내 압축 설정은 applicationHost.config 파일에서 다음과 같습니다

<httpCompression 
     directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files"> 
     <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" /> 
     <dynamicTypes> 
      <add mimeType="text/*" enabled="true" /> 
      <add mimeType="application/json" enabled="true" /> 
      <add mimeType="application/json; charset=utf-8" enabled="true" />     
      <add mimeType="message/*" enabled="true" /> 
      <add mimeType="application/x-javascript" enabled="true" /> 
      <add mimeType="*/*" enabled="false" /> 
     </dynamicTypes> 
     <staticTypes> 
      <add mimeType="text/*" enabled="true" /> 
      <add mimeType="message/*" enabled="true" /> 
      <add mimeType="application/json" enabled="true" /> 
      <add mimeType="application/json; charset=utf-8" enabled="true" />     
      <add mimeType="application/x-javascript" enabled="true" /> 
      <add mimeType="application/atom+xml" enabled="true" /> 
      <add mimeType="application/xaml+xml" enabled="true" /> 
      <add mimeType="*/*" enabled="false" /> 
     </staticTypes> 
    </httpCompression> 
+0

변경할 경우 = true로 사용할 수는 JSON 압축됩니까에 :

여기에 더 읽기입니까? 이 게시물은 해당 시나리오의 디버깅에 대해 언급합니다 (http://blogs.msdn.com/b/asiatech/archive/2013/02/19/unable-to-compress-json-result-in-iis-7-x.aspx) – Jedidja

+0

applicationHost.config 및 web.config의 url 압축 설정은 무엇입니까? – brucwhi

답변

1

% WinDir % \ System32 \ inetsrv \ config \ applicationHost.config에있는 IIS applicationHost.config 파일에 다음 코드 블록이 포함되어 있는지 확인하십시오.

<system.webServer> 
    <urlCompression doDynamicCompression="true" /> 
    <httpCompression> 
     <dynamicTypes> 
     <add mimeType="application/json" enabled="true" /> 
     <add mimeType="application/json; charset=utf-8" enabled="true" />  
     </dynamicTypes> 
    </httpCompression> 
</system.webServer> 
+0

아쉽게도 이러한 설정은 이미 TRUE로 설정되어 있습니다. 압축 설정으로 질문을 업데이트했습니다. –

0

구성이 올바른 것처럼 보입니다. IIS가 모든 것을 압축하기 시작하는 한계점에 도달하지 못했을 수 있습니다.

시도해보십시오. IIS 관리자에서 구성 편집기로 이동하여 system.WebServer/serverRuntime을 찾으십시오. frequentHitThreshold 및 frequentHitTimePeriod 설정을 살펴본 다음 테스트 할 때 임계 값을 충족 시키도록 보장하십시오. http://blogs.msdn.com/b/asiatech/archive/2013/02/19/unable-to-compress-json-result-in-iis-7-x.aspx

+0

죄송합니다.'frequentHitThreshold = 1' 설정을 시도했지만 여전히 도움이되지 않았습니다. –

관련 문제