简体   繁体   English

无法从WinRT连接到远程服务器

[英]Not able to connect to remote server from WinRT

I'm making an application which basically just needs to send a piece of XML to a server and return. 我正在创建一个基本上只需要将一段XML发送到服务器并返回的应用程序。 I'm having trouble however getting this to work and getting very strange errors 我遇到了麻烦,但要让它工作并得到非常奇怪的错误

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;

    }

The server I'm posting to is not localhost, but it is a computer on my local network. 我发布的服务器不是localhost,但它是我本地网络上的一台计算机。 I get this error deeply nested: 我深深嵌套这个错误:

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"}

I have the internet client capability on my application. 我的应用程序具有Internet客户端功能。 I can access my local network and internet by other store applications. 我可以通过其他商店应用访问我的本地网络和互联网。 I can access the resource in firefox get proper behavior. 我可以在firefox中访问资源获得正确的行为。 I don't have a firewall enabled nor an anti-virus that would block these ports 我没有启用防火墙,也没有阻止这些端口的防病毒软件

What could possibly cause this obscure error? 什么可能导致这个模糊的错误? How can I fix it? 我该如何解决?

To access the LAN, you must declare the Private Network capability in your application manifest. 要访问LAN,您必须在应用程序清单中声明Private Network功能。 Note that this is different than the Internet capability. 请注意,这与Internet功能不同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM