azure - TableController 类的用途是什么?它的方法在哪里使用?

标签 azure azure-sql-database azure-mobile-services

我开始使用 Azure,并选择在 VS 中使用 .NET 设置移动服务。我一直在了解 Azure Todo 入门服务器项目的组成部分。

我很难理解的一件事(即使进行了大量的谷歌搜索)是​​ TableController 方法的用途是什么?我了解 TableController 将表公开给 HTTP 请求?但是,当我从客户端访问数据时,我在 MobileServiceClient 实例返回的表上使用“.LookupAsync”或“.UpdateAsync”方法。

当我进行这些调用时,TableController 中的 GetAllToDoItems(..)、PathToDoItem(..)、GetToDoItem(..)、PostToDoItem(..)、DeleteToDoItem(..) 方法是否在幕后某处使用MobileServiceClient 表?

我可以从我的客户端访问这些方法吗?这些方法是标准/必需的方法名称吗?

TableController 是放置服务器代码进行授权的好地方吗?例如。仅返回该用户记录的经典示例?

感谢您的帮助, 汤姆。

最佳答案

Can I access those methods from my client? Are these methods standard/required method names?

目前,Azure移动应用支持C#和node.js作为其后端语言。来自 Get started article ,我们可以知道,无论您是构建 native iOS、Android 和 Windows 应用程序还是跨平台 Xamarin 或 Cordova (Phonegap) 应用程序,我们都可以利用使用 native SDK 的移动应用程序。我们可以在后端项目中看到很多函数,如 GetAllToDoItems(..)、PathToDoItem(..)、GetToDoItem(..)、PostToDoItem(..)、DeleteToDoItem(..)。此方法是 MVC Controller 操作名称。请注意,SDK 函数非常重要,如下所示,后端项目有一个名为 GetTodoItem 的函数。

     public SingleResult<TodoItem> GetTodoItem(string id)
        {
            return Lookup(id);
        }

但是命名空间“Microsoft.Azure.Mobile.Server”下的函数Lookup是该函数中的关键方法:

enter image description here

Is TableController a good place to put server code for authorisation? E.g. the classic example of only returning that user's records?

如果要添加身份验证,我认为this article可能会给你带来帮助。以Azure AD为例,如果要保护某个表 Controller ,我们只需要配置Azure AD,然后在表 Controller 前添加[Authorize]属性即可,不需要在该表 Controller 中添加授权代码。

关于azure - TableController 类的用途是什么?它的方法在哪里使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41091994/

相关文章:

c# - 使用 C# 的 Azure 文本分析给出错误

azure - 可以在 AZURE VM 中运行 Windows Phone 8 模拟器吗?

azure - 是否有办法将 Azure SQL 数据库从 VCORE 降级为 DTU 模型

azure - Azure SQL 数据库是分布式 SQL 数据库吗?

php - MySQL我连接不上?查询未运行

c# - Azure 移动服务 .Net 后端调度程序错误

azure - 合并两个具有不同列名的表 KQL

Azure 认知搜索分析器与标准化器,何时应该使用它们

c# - Azure 移动应用程序与自定义 Controller 离线同步

android - 使用Where语句的Windows Azure移动服务