简体   繁体   中英

does not contain definition for “Method”

I have a WCF application with SOAP and RESTful end points which I followed from this tutorial.

everything was working great I could call basicHttpbinding data. Now I am trying to call data from the RESTful side, I received this error when coding the

Error 1 'System.ServiceModel.Web.WebGetAttribute' does not contain a definition for 'Method'

the error is shown here:

[OperationContract]
    [WebGet(Method = "GET", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "getTrucksA")]
    List<RTrucks> GetTrucksA();

I did check out this question on Stack Overflow and tried all answers like

  • Removing using System.ServiceModel.Web and adding it again.
  • Adding Reference
  • changing the Framework target in my project settings

    but nothing works.

any ideas?

The WebGetAttribute does not have a property named Method . There is no need to set the method as WebGet always refers to a GET request. So remove the part Method = "Get", and you are good to go.

MS定义的WebGet不需要您发布的Method ='Get',因为WebGet是动词GET,可以将WebInvoke(Method ='POST')用于POST。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM