2017-05-16 206 views
0

最近,我將我的Azure後端項目從App Services推廣到移動服務。Xamarin。將Azure移動服務升級到應用服務--LastController

https://docs.microsoft.com/en-us/azure/app-service-mobile/app-service-mobile-net-upgrading-from-mobile-services

在項目中,我使用表控制器現在

[MobileAppController] 
public class ChildController : TableController<Child> 
{ 
    public Child GetChildByEmail(string email) 
    { 
     return _context.Children.SingleOrDefault(ch => ch.Email == email); 
    } 
} 

,之前的網址升級到GetChildByEmail方法是:

/api/child/email 

因此,我調用該方法如下:

Child result = await _service.MobileServiceClient.InvokeApiAsync<Child> 
("child", HttpMethod.Get, new Dictionary<string, string>() { { "email", 
email } }); 

它工作正常。但經過URL中的升級方法是

/tables/child/email 

所以InvokeApiAsync不工作,因爲它是調用

/api/child/email 

我試圖與「路徑」屬性

Route["api/child"] 
裝飾方法

但它沒有工作。有沒有辦法在TableController中保留該方法,並強制InvokeApiAsync調用/ tables/child/email而不是/ api/child/email?或者解決這個問題的唯一方法是將該方法移動到ApiContoller(工作正常)?

回答

0

我sovled問題:

config.Routes.MapHttpRoute("ActionApi", "api/{controller}");