开发者

Hide public Property when exposed through web service

开发者 https://www.devze.com 2022-12-26 07:16 出处:网络
I would like to prevent a property from being exposed via my WCF web service. I tried adding the XmlIgnore attribute bug that didn\'t work. We are using .NET 3.5. WCF.

I would like to prevent a property from being exposed via my WCF web service. I tried adding the XmlIgnore attribute bug that didn't work. We are using .NET 3.5. WCF.

This doesn't work:

    public class MyClass
    {
        public string S1 { get; set; }

        [XmlIgnore]
        pu开发者_运维技巧blic string S2NotExposed { get; set; }
    }


Mark your class with the [DataContract] attribute from the DataContractAttribute Class , then mark only the properties you want to expose with the [DataMember] attribute from the DataMemberAttribute Class.

0

精彩评论

暂无评论...
验证码 换一张
取 消