Simple URL routes in WCF Rest 4.0 without trailing slash

后端 未结 7 1422
太阳男子
太阳男子 2021-02-01 20:27

I have a WCF REST 4.0 project based on the the WCF REST Service Template 40(CS). I\'d like to expose simple service endpoint URLs without trailing slashes. For example:

相关标签:
7条回答
  • 2021-02-01 21:19

    You need a UriTemplate, Try something like this:

     [ServiceContract()]
     public interface ICarService
     {
    
         [OperationContract]
         [WebGet(UriTemplate = "/Car")]
         CarPool GetAllCars();
    
         [OperationContract]
         [WebGet(UriTemplate = "/Car/{carName}")]
         Car GetCar(string carName);
    
     }
    
    0 讨论(0)
提交回复
热议问题