azure sdk deleteAsync请求内容为null

时间:2015-01-03 17:19:37

标签: c# azure azure-sdk-.net

我有一个带有.NET后端的天蓝色移动服务,无法删除记录。当我调试Delete函数时,该项为null。当我在即时窗口中调用this.Request时,我会在底部返回字符串。我以前使用节点js后端,但已切换到.NET后端,因此客户端代码没有改变。

查看项目类:

public class ReviewItem
{
    public string Id { get; set; }
    public string Line1 { get; set; }
    public string Line2 { get; set; }
    public string Line3 { get; set; }
    public string Line4 { get; set; }
    public System.DateTime LastUpdated { get; set; }
}  

客户方:

var dbReviewItems = await reviewTable.ToListAsync();
foreach (var item in dbReviewItems)
    await reviewTable.DeleteAsync(item);

服务器端:

public void Delete(T item)
{
    Context.Delete(item.Id);
    Context.SaveChanges();
}

背景:

// passing in Id because passing the item caused a not found exception
public T Delete(string Id) 
{
    var item = Find(Id);
    if (item == null) return null;
    return Context.Set<T>().Remove(item);
}

Controller的请求(在调试模式下在Azure服务器上运行,从wp模拟器调用):

{Method: DELETE, RequestUri: 'https://xxxx.azure-mobile.net/tables/ReviewItem/016f5328-c6fa-4b14-9c41-73976a0afda8', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:  
{  
  Cache-Control: no-cache  
  Connection: Keep-Alive  
  Accept: application/json  
  Accept-Encoding: gzip  
  Host: xxxx.azure-mobile.net  
  Max-Forwards: 10  
  User-Agent: ZUMO/1.3  
  User-Agent: (lang=Managed; os=Windows Phone; os_version=8.10.0.12358; arch=Win32NT; version=1.3.21121.0)  
  X-ZUMO-FEATURES: TT  
  X-ZUMO-INSTALLATION-ID: xxxx  
  X-ZUMO-APPLICATION: xxxx  
  X-ZUMO-AUTH: xxxx  
  X-ZUMO-VERSION: ZUMO/1.3 (lang=Managed; os=Windows Phone; os_version=8.10.0.12358; arch=Win32NT; version=1.3.21121.0)  
  X-LiveUpgrade: 1  
  X-ARR-LOG-ID: xxxx  
  DISGUISED-HOST: xxxx.azure-mobile.net  
  X-SITE-DEPLOYMENT-ID: xxxx  
  X-Original-URL: /tables/ReviewItem/016f5328-c6fa-4b14-9c41-73976a0afda8  
  X-Forwarded-For: 70.186.182.236:4945  
  X-ARR-SSL: 2048|128|DC=com, DC=microsoft, DC=corp, DC=redmond, CN=MSIT Machine Auth CA 2|C=US, S=WA, L=Redmond, O=Microsoft, OU=OrganizationName, CN=*.azurewebsites.net  
  Content-Length: 0  
}}  
    Content: {System.Net.Http.StreamContent}  
    Headers: {Cache-Control: no-cache  
Connection: Keep-Alive  
Accept: application/json  
Accept-Encoding: gzip  
Host: xxxx.azure-mobile.net  
Max-Forwards: 10  
User-Agent: ZUMO/1.3 (lang=Managed; os=Windows Phone; os_version=8.10.0.12358; arch=Win32NT; version=1.3.21121.0)  
X-ZUMO-FEATURES: TT  
X-ZUMO-INSTALLATION-ID: xxxx  
X-ZUMO-APPLICATION: xxxx  
X-ZUMO-AUTH: xxxx  
X-ZUMO-VERSION: ZUMO/1.3 (lang=Managed; os=Windows Phone; os_version=8.10.0.12358; arch=Win32NT; version=1.3.21121.0)  
X-LiveUpgrade: 1  
X-ARR-LOG-ID: a252fe87-03c9-487a-87c8-aa454c906f79  
DISGUISED-HOST: xxxx.azure-mobile.net  
X-SITE-DEPLOYMENT-ID: xxxx  
X-Original-URL: /tables/ReviewItem/016f5328-c6fa-4b14-9c41-73976a0afda8  
X-Forwarded-For: 70.186.182.236:4945  
X-ARR-SSL: 2048|128|DC=com, DC=microsoft, DC=corp, DC=redmond, CN=MSIT Machine Auth CA 2|C=US, S=WA, L=Redmond, O=Microsoft, OU=OrganizationName, CN=*.azurewebsites.net  
}  
    Method: {DELETE}  
    Properties: Count = 11  
    RequestUri: {https://xxxx.azure-mobile.net/tables/ReviewItem/016f5328-c6fa-4b14-9c41-73976a0afda8}  
    Version: {1.1}

1 个答案:

答案 0 :(得分:0)

我是一个愚蠢的哑巴。我让控制器的删除方法接收一个对象。它应该接收一个字符串Id。