【发布时间】:2017-09-28 11:39:21
【问题描述】:
我是 Windows 应用程序开发的新手。我正在尝试使用具有以下代码块的移动服务客户端使用服务 api
MobileServiceClient mSClient;
mSClient = new MobileServiceClient("https://*******.azure-mobile.net/", "UFakeKkrayuAeVnosdfghrwvnhdfVAcjYziYFSFHUV89");
Dictionary<string, string> userobj = new Dictionary<string, string>();
userobj.Add("UserName", "username");
userobj.Add("Password", "password");
userobj.Add("DeviceUID", "010092780200134E0300215F0400CC37050083D807006B9B080066010900267F");
userobj.Add("DeviceToken", "device_123");
userobj.Add("OSVersion", "WindowsPhone");
userobj.Add("AppVersion", "2.0");
userobj.Add("DeviceModel", "Windows phone");
userobj.Add("DeviceTypeID", "1");
userobj.Add("DeviceAlertsOn","true");
var responce = mSClient.InvokeApiAsync("user/loguserin", HttpMethod.Post, userobj);
但我没有得到适当的回应:
谁能帮我解决这个问题?
谢谢, 斯里尼瓦斯。
【问题讨论】:
-
调用异步方法时需要使用await
-
添加到 jason 和 sushi,当你不使用 await 时,你的响应将包含任务对象。您可以从
responce对象访问状态和错误。然后您可以稍后执行await responce来运行它。这有助于更多的调试 -
谢谢 Neville,能否请您给我一些适当的代码块以获得响应
-
你写的方式很好。您可以在调试模式下检查对象。只需在该行下方添加
await responce行。我经常这样做是为了测试异步函数
标签: c# xamarin asp.net-web-api