我正在使用Windows Phone/Store应用程序的新运行时使用Windows Universal应用程序.我正在使用以下代码向服务器发送请求并期望返回HTML响应.但是,当我返回字符串并在UI中显示它时,它只是说:
"System.Threading.Tasks.Task'1 [System.String]"
它没有向我显示应该返回的实际HTML/XML.当我在普通的Windows窗体应用程序中使用相同的URL时,它返回我期望的数据,但我在那里使用的代码是不同的,因为它是Win32而不是WinRT /这个新的RT.
这是我的代码.我怀疑我没有以正确的格式返回数据,但我不知道我应该做什么.
var url = new Uri("http://www.thewebsitehere.com/callingstuff/calltotheserveretc");
var httpClient = new HttpClient();
try
{
var result = await httpClient.GetStringAsync(url);
string checkResult = result.ToString();
httpClient.Dispose();
return checkResult;
}
catch (Exception ex)
{
string checkResult = "Error " + ex.ToString();
httpClient.Dispose();
return checkResult;
}
Run Code Online (Sandbox Code Playgroud)