Ear*_*rlz 5 .net c# networking windows-runtime dotnet-httpclient
我正在创建一个基本上只需要将一段XML发送到服务器并返回的应用程序.我遇到了麻烦,但要让它工作并得到非常奇怪的错误
public bool Post(string data)
{
string server="http://my-lan-computer:9091/foo"
bool success = false;
HttpClient client = new HttpClient();
try
{
client.PostAsync(server, new StringContent(data, Encoding.UTF8, "text/xml")).Wait(); //error here
success = true;
} catch { }
return success;
}
Run Code Online (Sandbox Code Playgroud)
我发布的服务器不是localhost,但它是我本地网络上的一台计算机.我深深嵌套这个错误:
innerException: {"An error occurred while sending the request."}
innerException: {"Unable to connect to the remote server"}
innerException: {"An attempt was made to access a socket in a way forbidden by its access permissions 123.123.123.123:9091"}
Run Code Online (Sandbox Code Playgroud)
我的应用程序具有Internet客户端功能.我可以通过其他商店应用访问我的本地网络和互联网.我可以在firefox中访问资源获得正确的行为.我没有启用防火墙,也没有阻止这些端口的防病毒软件
什么可能导致这个模糊的错误?我该如何解决?
| 归档时间: |
|
| 查看次数: |
1970 次 |
| 最近记录: |