C# Windows Phone HttpClient PostAsync在响应之前返回

C# Windows Phone HttpClient PostAsync在响应之前返回,c#,windows-phone-8,dotnet-httpclient,C#,Windows Phone 8,Dotnet Httpclient,在服务器发送响应之前,我有一段Windows phone应用程序代码返回。我知道,我需要同步调用它,但我尝试了各种选项,但失败了。下面是一段代码 string finalUri = ServerConstants.serverName + "PCUserSignUP"; string postString = "email=" + uEmail + "&password=" + uPass; Debug.WriteLine(finalUri); signUpReq.DefaultRequ

在服务器发送响应之前,我有一段Windows phone应用程序代码返回。我知道,我需要同步调用它,但我尝试了各种选项,但失败了。下面是一段代码

string finalUri = ServerConstants.serverName + "PCUserSignUP";
string postString = "email=" + uEmail + "&password=" + uPass;
Debug.WriteLine(finalUri);
signUpReq.DefaultRequestHeaders.ExpectContinue = false;
//signUp_result = await signUpReq.GetStringAsync(finalUri);
var response = await signUpReq.PostAsync(finalUri, new StringContent(postString)).ConfigureAwait(true);
//signUp_result = strResult;
//Debug.WriteLine("Result=" + strResult);

response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Debug.WriteLine("response body="+responseBody);
var userJsonObj = (signUpResponseJSON)JsonConvert.DeserializeObject<signUpResponseJSON>(responseBody);
if(userJsonObj.response.Equals("success",StringComparison.OrdinalIgnoreCase))
{
    UserProfile.getUserProfile().updatePcId(userJsonObj.pcid);
    signUp_result = userJsonObj.pcid;
}
//UserProfile.
string finalUri=ServerConstants.serverName+“PCUserSignUP”;
string postString=“email=“+uEmail+”&password=“+uPass;
Debug.WriteLine(finalUri);
signUpReq.DefaultRequestHeaders.ExpectContinue=false;
//signUp_result=等待signUpReq.GetStringAsync(finalUri);
var response=await signUpReq.PostAsync(finalUri,newstringcontent(postString)).ConfigureAwait(true);
//注册结果=stresult;
//Debug.WriteLine(“Result=“+strResult”);
response.EnsureSuccessStatusCode();
string responseBody=wait response.Content.ReadAsStringAsync();
Debug.WriteLine(“response body=“+responseBody”);
var userJsonObj=(signUpResponseJSON)JsonConvert.DeserializeObject(ResponseBy);
if(userJsonObj.response.Equals(“success”,StringComparison.OrdinalIgnoreCase))
{
UserProfile.getUserProfile().updatePcId(userJsonObj.pcid);
signUp_result=userJsonObj.pcid;
}
//用户配置文件。

我尝试了.Result和ConfigureAwait(false),没有任何效果…如何修复此问题。在我使用GET之前,它一直运行良好,但在我移动到PostAsync的那一刻,它停止了工作,而且我是否正确地使用了StringContent?

很抱歉,听起来可能有些屈尊俯就,但您的方法是否明确标记了
async
修饰符?我正在使用Wait,但响应仍然为空,如果我在POST中尝试浏览器中的URL,它会工作得很好。另一个指示是,如果我在postasync语句中添加.Result,它将永远不会返回。它一直在运行…我怀疑,我的查询字符串没有正确传递,不管怎样检查它?状态代码:200,原因短语:“确定”,版本:0.0,内容:System.Net.Http.StreamContent,标题:{服务器:Apache Coyote/1.1日期:2014年3月10日星期一14:36:42 GMT X-Cache:MISS from proxy-server5-int2连接:keep-alive内容长度:0}这是响应,代理服务器遗漏了什么?它在说什么吗?