不能从WinRT的连接到远程服务器 [英] Not able to connect to remote server from WinRT

查看:111
本文介绍了不能从WinRT的连接到远程服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在做,基本上只需要发送一条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.

这篇关于不能从WinRT的连接到远程服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆