当您使用REST';是webinvoke还是webget

本文关键字:webinvoke 还是 webget REST | 更新日期: 2023-09-27 17:57:32

[WebInvoke(UriTemplate = "/GetContent", RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
public List<Content> GetContent(string path) {
        return Utility.GetContent(path);
    }
[OperationContract]
[WebInvoke(UriTemplate = "/GetContent", RequestFormat = WebMessageFormat.Json,     BodyStyle = WebMessageBodyStyle.Wrapped)]
public List<Content> GetContent(string path) {
    return Utility.GetContent(path);
}

这两种方法的作用相同还是有所不同?看起来它们都适用于我。

当您使用REST';是webinvoke还是webget

OperationContractAttribute属性声明方法是服务协定中的操作。只有具有OperationContractAttribute属性的方法才作为服务操作公开。没有任何用OperationContractAttribute标记的方法的服务约定不会公开任何操作。