How to add maxItemsInObjectGraph programmatically without using configuration file?

前端 未结 3 2061
陌清茗
陌清茗 2021-02-20 06:39

I have create a EndpointAddress like that

EndpointAddress address = new EndpointAddress(\"http://example.com/services/OrderService.svc\");

But

3条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-20 07:00

    On Server Side, you can also:

    ServiceHost host = new ServiceHost();
    ServiceBehaviorAttribute sba = host .Description.Behaviors.Find();
                if (sba == null)
                {
                    sba = new ServiceBehaviorAttribute();
                    sba.MaxItemsInObjectGraph = int.MaxValue;
                    host.Description.Behaviors.Add(sba);
    }
    

提交回复
热议问题