Optional query string parameters in URITemplate in WCF?

前端 未结 5 1747
盖世英雄少女心
盖世英雄少女心 2020-12-17 07:55

I\'m developing some RESTful services in WCF 4.0. I\'ve got a method as below:

[OperationContract]
    [WebGet(UriTemplate = \"Test?format=XML&records={r         


        
5条回答
  •  感情败类
    2020-12-17 08:07

    This seems to work in WCF 4.0.
    Just make sure to set your default value in your "Service1.svc.cs"

    public string TestXml(string records)
    {
      if (records == null)
          records = "10";
    
      //... rest of the code
    }
    

提交回复
热议问题