Azure服务教程:HttpResponseMessage'不包含'StatusDescription&

本文关键字:包含 StatusDescription Azure 教程 HttpResponseMessage 服务 | 更新日期: 2023-09-27 18:15:11

我正在学习Azure移动服务入门教程:

http://www.windowsazure.com/en-us/develop/mobile/tutorials/validate-modify-and-augment-data-dotnet/

在步骤4中,教程添加了一个异常处理程序,catch代码对我来说有一个编译错误。

catch (MobileServiceInvalidOperationException e)
{
    MessageDialog errormsg = new MessageDialog(e.Response.Content, 
        string.Format("{0} (HTTP {1})",                     
        e.Response.StatusDescription,      // ERROR *
        e.Response.StatusCode));
    var ignoreAsyncOpResult = errormsg.ShowAsync();
  • System.Net.Http。HttpResponseMessage'不包含'StatusDescription'的定义

看起来类在构建演示之后发生了变化。
有什么合适的吗?

Azure服务教程:HttpResponseMessage'不包含'StatusDescription&

这是文档中的一个错误,感谢您指出来。属性名应该是ReasonPhrase,正确的代码应该是:

catch (MobileServiceInvalidOperationException e)
{
    MessageDialog errormsg = new MessageDialog(e.Response.Content, 
        string.Format("{0} (HTTP {1})",                     
        e.Response.ReasonPhrase,
        (int)e.Response.StatusCode));
    var ignoreAsyncOpResult = errormsg.ShowAsync();
}

我会通知团队修复。