Enable WCF Data Service to accept/return JSON by default
问题 I have a WCF Data Service that I'd like to return JSON by default for all operations. Is there a place I can set that in configuration/via service attributes? 回答1: In order to enable json via the $format tag like this: host:8038/YourService.svc/?$format=json Add this attribute to your service declaration: [JSONPSupportBehavior] public class Service : DataService<YourEntities> Add this as a class to your service: using System; using System.ServiceModel; using System.ServiceModel.Channels;