문제

How to declare optional parameters in UriTemplate in WCF Web Api ? For example :

[WebGet(UriTemplate = "?culture={culture}")]
HttpResponseMessage<IEnumerable<Contact>> GetAll();

I need culture to be optional parameter. If culture is not passed I want to receive null for that param.

PS. I don't want to create solution with multiple GetAll methods with different UriTemplates...

도움이 되었습니까?

해결책

With the following method declaration culture parameter will be null

[WebGet(UriTemplate = "?culture={culture}")]
HttpResponseMessage<IEnumerable<Contact>> GetAll(string culture);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top