雖然依一般設計實務,多半建議使用者在瀏覽過程中,用到多少資料再傳多少資料,真正需要一口氣傳回大量資料的場合不多。但如真有需要,可在web.config加入以下設定,就可以將項目上限調到2G囉!
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
<!-- Set maxItemsInObjectGraph -->
<services>
<service name="MyNamespace.MyDomainServiceClass"
behaviorConfiguration="MyWCFConfig"></service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyWCFConfig">
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>