2017-02-14 74 views
0

使用Azure移動客戶端SDK時,除了網址以外,似乎無法控制將要命中的REST終點的URL。默認情況下,請求將轉到(GET)www.myurl.com/tables/entity以返回所有實體。我可以做些什麼來注入實體之間的版本號,如/tables/v1/entity?我知道我可以做www.myurl.com/v1/tables/entity但這不是我正在尋找的解決方案。謝謝。使用Azure移動客戶端SDK的備用URI

+0

MobileClient專門用於與Azure移動服務後端交談。如果您將它用於自定義後端,則您必須從源代碼中分叉。 –

回答

0

從我的測試中,我們可以使用屬性來實現這種情況。以下是具體步驟:

1)添加config.MapHttpAttributeRoutes在啓動文件

HttpConfiguration config = new HttpConfiguration(); 

      //For more information on Web API tracing, see http://go.microsoft.com/fwlink/?LinkId=620686 
      config.EnableSystemDiagnosticsTracing(); 
      config.MapHttpAttributeRoutes(); 
      new MobileAppConfiguration() 
       .UseDefaultConfiguration() 
       .ApplyTo(config); 

2)添加屬性路線的方法要自定義域。

[Route("tables/v1/todoitem")] 
     // GET tables/TodoItem 
     public IQueryable<TodoItem> GetAllTodoItems() 
     { 
      return Query(); 
     } 

以下是我本地的結果:

enter image description here

希望這可以給你一些提示。

相關問題