WPF应用程序中Azure移动应用服务的问题



我是移动应用服务和Azure的新手,我想让应用程序服务层工作,然后将其移植到Xamarin App,所以我认为我只需尝试一个简单的WPF应用程序消费服务。

我在Azure提供的.NET/C#中下载了示例服务,并发布了它,但是我得到了这些例外并感到困惑。

这是客户端代码,它引发了不良请求例外,我尝试了多个对应用程序服务的调用,例如插入,更新等,但它们都失败了。

string url = @"https://mydomain.azurewebsites.net";
MobileServiceClient client = new MobileServiceClient(url);
return await client.GetTable<TodoItem>().ToListAsync();
public class TodoItem
{
    string id;
    string name;
    bool done;
    [JsonProperty(PropertyName = "id")]
    public string Id
    {
        get { return id; }
        set { id = value; }
    }
    [JsonProperty(PropertyName = "text")]
    public string Name
    {
        get { return name; }
        set { name = value; }
    }
    [JsonProperty(PropertyName = "complete")]
    public bool Done
    {
        get { return done; }
        set { done = value; }
    }
}

应用程序服务待遇

public class TodoItem : EntityData
    {
        public string Text { get; set; }
        public bool Complete { get; set; }
    }

代码todocontroller

    // GET tables/TodoItem
    public IQueryable<TodoItem> GetAllTodoItems()
    {
        return Query();
    }
    // GET tables/TodoItem/48D68C86-6EA6-4C25-AA33-223FC9A27959
    public SingleResult<TodoItem> GetTodoItem(string id)
    {
        return Lookup(id);
    }
    // PATCH tables/TodoItem/48D68C86-6EA6-4C25-AA33-223FC9A27959
    public Task<TodoItem> PatchTodoItem(string id, Delta<TodoItem> patch)
    {
        return UpdateAsync(id, patch);
    }
    // POST tables/TodoItem
    public async Task<IHttpActionResult> PostTodoItem(TodoItem item)
    {
        TodoItem current = await InsertAsync(item);
        return CreatedAtRoute("Tables", new { id = current.Id }, current);
    }
    // DELETE tables/TodoItem/48D68C86-6EA6-4C25-AA33-223FC9A27959
    public Task DeleteTodoItem(string id)
    {
        return DeleteAsync(id);
    }

应用程序记录和异常

Method: GET, RequestUri: 'https://mydomain.azurewebsites.net/tables/TodoItem', Version: 1.1, Content: <null>, Headers:
{
  X-ZUMO-FEATURES: TT
  X-ZUMO-INSTALLATION-ID: cd7127a1-efc4-4967-b646-e99a069976cb
  Accept: application/json
  User-Agent: ZUMO/1.3
  User-Agent: (lang=Managed; os=Windows; os_version=6.1.65536.7601; arch=Win32NT; version=1.3.30324.0)
  X-ZUMO-VERSION: ZUMO/1.3 (lang=Managed; os=Windows; os_version=6.1.65536.7601; arch=Win32NT; version=1.3.30324.0)
}}
{StatusCode: 400, ReasonPhrase: 'Bad Request', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
  Date: Thu, 02 Mar 2017 02:44:30 GMT
  Set-Cookie: ARRAffinity=1b2631dc149e564d651190bdb0b6895025c984e8ad5bea83fb1e545ec292facb;Path=/;Domain=mydomain.azurewebsites.net
  Server: Microsoft-IIS/8.0
  X-Powered-By: ASP.NET
  Content-Length: 220
  Content-Type: application/json; charset=utf-8
}}
Application: 2017-03-02T03:48:26  PID[6016] Information Request, Method=GET, Url=https://mydomain.azurewebsites.net/tables/TodoItem, Message='https://mydomain.azurewebsites.net/tables/TodoItem'
Application: 2017-03-02T03:48:26  PID[6016] Information Message='TodoItem', Operation=DefaultHttpControllerSelector.SelectController
Application: 2017-03-02T03:48:26  PID[6016] Information Message='mydomainService.Controllers.TodoItemController', Operation=DefaultHttpControllerActivator.Create
Application: 2017-03-02T03:48:26  PID[6016] Information Message='mydomainService.Controllers.TodoItemController', Operation=HttpControllerDescriptor.CreateController
Application: 2017-03-02T03:48:53  PID[6016] Information Message='Selected action 'GetAllTodoItems()'', Operation=ApiControllerActionSelector.SelectAction
Application: 2017-03-02T03:48:53  PID[6016] Information Operation=HttpActionBinding.ExecuteBindingAsync
Application: 2017-03-02T03:48:53  PID[6016] Information Operation=TableQueryFilter.OnActionExecutingAsync
Application: 2017-03-02T03:48:53  PID[6016] Information Operation=EnableQueryAttribute.OnActionExecutingAsync
Application: 2017-03-02T03:48:53  PID[6016] Information Message='Will use same 'JsonMediaTypeFormatter' formatter', Operation=JsonMediaTypeFormatter.GetPerRequestFormatterInstance
Application: 2017-03-02T03:48:53  PID[6016] Information Message='Selected formatter='JsonMediaTypeFormatter', content-type='application/json; charset=utf-8'', Operation=DefaultContentNegotiator.Negotiate
Application: 2017-03-02T03:48:53  PID[6016] Information Operation=TableControllerConfigAttribute.OnActionExecutingAsync, Status=400 (BadRequest)
Application: 2017-03-02T03:48:53  PID[6016] Information Operation=EnableQueryAttribute.OnActionExecutedAsync, Status=400 (BadRequest)
Application: 2017-03-02T03:48:53  PID[6016] Information Operation=TableQueryFilter.OnActionExecutedAsync, Status=400 (BadRequest)
Application: 2017-03-02T03:48:54  PID[6016] Information Operation=TodoItemController.ExecuteAsync, Status=400 (BadRequest)
Application: 2017-03-02T03:48:54  PID[6016] Information Response, Status=400 (BadRequest), Method=GET, Url=https://mydomain.azurewebsites.net/tables/TodoItem?$select=Text,Complete,Id,Version,CreatedAt,UpdatedAt,Deleted, Message='Content-type='application/json; charset=utf-8', content-length=unknown'
Application: 2017-03-02T03:48:54  PID[6016] Information Operation=JsonMediaTypeFormatter.WriteToStreamAsync
Application: 2017-03-02T03:48:55  PID[6016] Information Operation=TodoItemController.Dispose

我会倒带,然后再次浏览教程。您做错了什么,没有提供足够的信息来说什么。明确地,您尚未包含实际在执行查询的代码。

相关内容

  • 没有找到相关文章

最新更新