我正在使用 azure 的默认服务器 (.net) 和默认 (uwp) 应用程序来测试移动应用程序系统。
发布服务器并通过应用程序连接到服务器后,我收到消息“请求无法完成。(错误请求)”。我没有修改任何东西。这是从 Azure 门户下载的默认项目。
响应是:
{StatusCode: 400, ReasonPhrase: 'Bad Request', Version: 1.1, Content: System.Net.Http.StreamContent, Headers: { 服务器:Microsoft-IIS/10.0 日期:2016 年 5 月 15 日星期日 18:22:48 GMT X-Powered-By:ASP.NET x-zumo-服务器版本:net-1.1.157.1 内容长度:228 内容类型:application/json;字符集=utf-8 }}
客户待办事项:
public class TodoItem
{
public string Id { get; set; }
[JsonProperty(PropertyName = "text")]
public string Text { get; set; }
[JsonProperty(PropertyName = "complete")]
public bool Complete { get; set; }
}
客户端逻辑:
private async void ButtonSave_Click(object sender, RoutedEventArgs e)
{
var todoItem = new TodoItem { Text = TextInput.Text };
TextInput.Text = "";
await InsertTodoItem(todoItem);
}
private async Task InsertTodoItem(TodoItem todoItem)
{
// This code inserts a new TodoItem into the database. When the operation completes
// and Mobile Apps has assigned an Id, the item is added to the CollectionView
await todoTable.InsertAsync(todoItem);
items.Add(todoItem);
//await App.MobileService.SyncContext.PushAsync(); // offline sync
}
我可以做什么来运行连接/系统?
谢谢
请您参考如下方法:
我发现每当我执行以下操作之一时,我都会收到此错误:
当客户端或服务器数据模型与数据库不匹配时,客户端或服务器应用程序都没有更改数据库表的权限。在这种情况下,您必须在 SQL Server Management Studio 中手动删除所有数据库表并运行客户端以使用数据模型中的最新更改重新生成表。或者您必须应用迁移。
当您从客户端向表中插入数据并且该表有外键列时,您为外键列提供了一个值,而外键表还没有值。
例如:
var todoItem= new TodoItem
{
Name = "Buying some food",
UserId = "1" // this will cause the same error if the user table is empty
};
当您尝试插入此项时,如果用户表为空,这将导致相同的错误
