不能从WinRT的连接到远程服务器连接到、服务器、WinRT

由网友(い我颠覆世界,只为你摆正)分享简介:我在做,基本上只需要发送一条XML到一个服务器,并返回一个应用程序。我有麻烦但得到这个工作,变得非常奇怪的错误I'm making an application which basically just needs to send a piece of XML to a server and return. I'm...

我在做,基本上只需要发送一条XML到一个服务器,并返回一个应用程序。我有麻烦但得到这个工作,变得非常奇怪的错误

I'm making an application which basically just needs to send a piece of XML to a server and return. 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. 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"}

我有我的应用程序的网络客户端功能。我可以通过其他的存储应用程序访问我的本地网络和互联网。我可以访问Firefox中的资源得到正确的行为。我没有启用防火墙,也不是反病毒会阻止这些端口

I have the internet client capability on my application. I can access my local network and internet by other store applications. I can access the resource in firefox get proper behavior. 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. Note that this is different than the Internet capability.

阅读全文

相关推荐

最新文章