c# - 请求无法完成(未找到)

标签 c# azure windows-store-apps azure-mobile-services

我添加了一个普通的移动服务,一直选择默认值。它是一个 .Net 后端,在我在北欧 DC 使用的现有服务器上使用新的 20MB 数据库。我创建了一个空白的 Windows 应用商店应用程序,添加了 MobileServices nuget 包,然后按照说明通过将 MobileServicesClient 添加到我的 App.xaml 类来将我的 MobileService 连接到我的应用程序。然后我添加了一个带有事件处理程序的按钮。该处理程序调用异步函数将 TodoItem 对象插入数据库。

应用程序.xaml.cs

public static MobileServiceClient MobileService = new MobileServiceClient(
             "https://???.azure-mobile.net/",
             "???");

我已将 URI 和 token 替换为 ???。我使用的来自此移动服务的 Azure 门户。

MainPage.xaml.cs

private void Button_Click(object sender, RoutedEventArgs e)
{
    CreateItem();
}

private async  void CreateItem()
{
    TodoItem item = new TodoItem { Text = "Sort This", Complete = false };
    try
    {
        await App.MobileService.GetTable<TodoItem>().InsertAsync(item);
    }
    catch(MobileServiceInvalidOperationException ex1)
    {
        Debug.WriteLine(ex1.Message);
    }
    catch(Exception ex)
    {
        Debug.WriteLine(ex.Message);
    }
}

当我运行此代码并单击按钮时,会引发 MobileServiceInvalidOperationException:

"{"请求无法完成。 (未找到)"}"

我使用的是 VS2013,安装了 Service Pack 2 和 WindowsAzure.MobileServices 1.2.3。

MobileService 正在运行,我可以导航到 https://MyMobileService.azure-mobile.net/但是,如果我单击“查看”,系统会要求我进行身份验证(MyMobileService 不是实际的 Uri)。

post 请求看起来没问题,但响应是 404。

我一整天都在做这个工作,包括使用 Windows Phone,但没有运气......

我知道我一定做错了什么,或者北欧的 Azure 存在问题,但我无法解决。

非常感谢任何帮助。

杰森。

最佳答案

不久前我也遇到了同样的问题。我从 .net 后端切换到 javascript。另外,请确保您的移动服务和数据库架构匹配。

关于c# - 请求无法完成(未找到),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24986250/

相关文章:

windows-8 - 基本页与空白页

c# - Json.net Collection 具有固定大小

azure - Azure 网站上的经典 ASP 网站,远程 mysql 数据库

azure - 宇宙数据库 : Can't create more than 25 containers in a shared database

azure - 软件开发启动: Signing into Microsoft services

c# - 如何使用 JavaScript 找到预定义按钮类 Windows 8 应用程序

c# - 当用户更新我的应用程序时,本地存储会被删除吗?

c# - 样式化 WinForm 的控件

c# - 邮件消息的“收件人”、“抄送”、“密件抄送”允许为 null (system.net.mail.mailmessage)

c# - 哪个本地数据库适合Windows 8 Store Apps?