maxItemsInObjectGraph ignored

前端 未结 5 1213
野性不改
野性不改 2021-01-12 09:33

I have a problem with a WCF service, which tries to serialize too much data. From the trace I get an error which says that the maximum number of elements that can be seriali

5条回答
  •  無奈伤痛
    2021-01-12 10:05

    Any setting put in the web.config were happily ignored, I haven't found out why. But I found a workaround, that is, to put the MaxItemsInObjectGraph as a class decoration. This works flawlessly:

    // MyService.svc
    // using...
    
    namespace MyNamespace {
      [ServiceContract]
      [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
      [ServiceBehavior(MaxItemsInObjectGraph = 65536000)]
      public class MyWebService {
    
        [OperationContract]
        [WebGet(UriTemplate = "tree/{sessionId}", ResponseFormat = WebMessageFormat.Json)]
        public MyData GetTree(string sessionId) {
        ...
    ...
    

提交回复
热议问题