WebRequest does not contain a definition for 'GetResponse' for Windows 10 Universal App

雨燕双飞 提交于 2019-12-06 15:04:18

in the answer you linked there is a comment with the actual answer:

In case it is a Windows Store App (and not WPF) there is no synchronous GetResponse method in class WebResponse

you have to use the async methods in UWP apps since they don't have synchronous cals anymore to improve user interface performance (no more hanging UI because it's doing a web request on the same thread)

your code should be in the form of

HttpWebResponse response = await webrequest.GetResponseAsync();

Here is some more info on async/await and how to use it: https://msdn.microsoft.com/en-us/library/hh191443.aspx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!