【问题标题】:Xamarin. Upgrade Azure Mobile Service to App Service - TableController赛马林。将 Azure 移动服务升级到应用服务 - TableController
【发布时间】:2017-05-16 06:43:56
【问题描述】:

最近我将 Azure 后端项目从应用服务升级到移动服务。

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 方法的 url 是:

/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”属性装饰方法

Route["api/child"]

但它不起作用。有没有办法将该方法保留在 TableController 中并强制 InvokeApiAsync 调用 /tables/child/email 而不是 /api/child/email?或者解决该问题的唯一方法是将方法移至 ApiContoller(工作正常)?

【问题讨论】:

    标签: .net azure xamarin


    【解决方案1】:

    我解决了这个问题:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-29
      • 2020-09-04
      相关资源
      最近更新 更多