2013-03-27 81 views
3

默認值我有一個DTO具有定義異常與路線

 [Route("/route/{Id}/{Status}")] 
     public class JustIdAndStatus : IReturn { 
      public long Id { get; set; } 
      public long Status { get; set; } 
     } 

然後我調用服務的東西,如

本地主機以下路線:9040 /路線/百分之一

localhost:9040/route/0/100

並且一切順利。

但是當我使用其中一個服務客戶端時,如果任何值爲0(長爲默認值),我會得到一個異常。

var client = new JsonServiceClient("http://127.0.0.1:9040"); 

    var request = new JustIdAndStatus() { 
        Id = 0, 
        Status = 1 
       }; 

    var response = client.Get(request); 

我得到的例外是

System.InvalidOperationException : None of the given rest routes matches 'JustIdAndStatus' request: 
    /route/{Id}/{Status}: Could not match following variables: Id 
    at ServiceStack.ServiceClient.Web.UrlExtensions.ToUrl(IReturn request, String httpMethod, String formatFallbackToPredefinedRoute) in UrlExtensions.cs: line 65 
    at ServiceStack.Common.Tests.UrlExtensionTests.Can_create_url_with_JustIdAndStatus(Int64 id, Int64 status) in UrlExtensionTests.cs: line 91 

我的問題找到了這個承諾的服務棧庫 https://github.com/ServiceStack/ServiceStack/commit/b34a5906a265da19d916ea47ee80783bd866abcb

我注意到,當我更新從ServiceStack 38年9月3日至來自nuget的3.9.40。

我想知道如果這種行爲是正確的,所以我用錯誤的方式使用路線,或者這可能是一個問題,可以提交給github上的問題跟蹤器。

我也做一個測試使用的是基本的人我事先就ServiceStack.Commons源代碼

https://gist.github.com/anonymous/5216727

感謝找到了!

回答

3

我同意你的看法,你所描述的應該是預期行爲,其中路徑中特別引用了該屬性。

您引用的提交旨在禁止在成員被轉移到查詢字符串的路由上使用默認參數值。但是,它似乎也會導致您用明確的路線描述的問題。

我在一起解決問題的拉請求,並添加一些測試以反映預期的行爲。

+0

更新:拉取請求已完成併合並。 – 2013-04-04 22:32:10