我已经使用了this thread中的提示并提供了一个默认值,以便当用户不指定虚拟子目录时,我假定他意味着所有的东西都是上市。有用。WCF中的UriTemplate中的可选参数
[OperationContract]
[WebInvoke(UriTemplate = "GetStuff/{type=all}", ...]
IEnumerable<Stuff> GetStuff(String type);
但是,改为指定默认值会更好。但是,默认(字符串)是null,我想以实际值发送。特别是,我已经设定了我的心脏String.Empty。但是,我注意到以下情况不起作用。服务器端的条件无法识别空字符串(...(ColName,'','all'))中的'type'。
[OperationContract]
[WebInvoke(UriTemplate = "GetStuff/{type=String.Empty}", ...]
IEnumerable<Stuff> GetStuff(String type);
怎么办?
Darn ...谢谢。 :) –