c# - 获取json数据时无法连接到远程服务器Windows 8.1 App
问题描述
我尝试使用以下方法从 Windows 8.1 应用程序获取一些 json 数据:
public async Task<string> Get(string Url)
{
try
{
var request = (HttpWebRequest)WebRequest.Create(Url);
HttpWebResponse response = await request.GetResponseAsync() as HttpWebResponse;
Stream responseStream = response.GetResponseStream();
using (StreamReader sr = new StreamReader(responseStream))
{
//Need to return this response
string strContent = sr.ReadToEnd();
return strContent;
}
}
catch (Exception e)
{
throw e;
}
}
我得到了这个异常:连接尝试失败,因为连接的一方在一段时间后没有正确响应,或者建立连接失败,因为连接的主机没有响应 ServerIP:80
尽管我在 Windows 10 UMP App 上使用了相同的代码,但没有错误,我得到了我的数据。
请问Windows 8.1 应用有什么问题?
解决方案
推荐阅读
- python - My code returns one correct review and NULL instead of the other reviews
- react-native - Network call from native module instead from Javascript/React Native
- mysql - 在 TRIGGER 中使用 INFORMATION_SCHEMA.COLUMNS 记录对 _all_ 列的更改?
- groovy - How to compare values in groovy
- javascript - Javascript convert date and time today and save .txt file using its format
- java - TarsosDSP pitch shifting artifacts
- java - CriteriaBuilder - Debug - NamedParameterDescriptor and query.getParameters() - Console IDE / log - Show name parameters and values
- c - Embedded system: How to identify required tasks/threads?
- oracle - Oracle HCM 云 API - 按 HireDate 获取员工
- html - 使用flex居中动态div数