Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/274.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 无法从WinRT连接到远程服务器_C#_.net_Networking_Windows Runtime_Dotnet Httpclient - Fatal编程技术网

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

C# 无法从WinRT连接到远程服务器,c#,.net,networking,windows-runtime,dotnet-httpclient,C#,.net,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 {

我正在制作一个应用程序,它基本上只需要将一段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;

    }
我发布到的服务器不是本地主机,但它是本地网络上的一台计算机。我发现这个错误非常严重:

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"}
我的应用程序具有internet客户端功能。我可以通过其他商店应用程序访问本地网络和internet。我可以访问firefox中的资源以获得正确的行为。我没有启用防火墙,也没有阻止这些端口的反病毒


什么可能导致这个模糊的错误?如何修复它?

要访问LAN,您必须在应用程序清单中声明
专用网络
功能。请注意,这与
互联网
功能不同

似乎响应可能来自服务器。服务器是什么?是IIS吗?某种WCF服务?你能查一下web.config吗?签入Fiddler以比较来自WinRT应用程序和成功连接到同一服务的另一个客户端的请求?也许它对http谓词或请求头有特定的要求?呵呵,没有注意到这个选项。奇怪的是,这是一个星期前的工作。我认为强制执行可能在开发过程中被“破坏”,但一些windows update或visual studio update为那些无法找到其应用程序的用户修复了它。无清单文件:它是解决方案资源管理器中的.appxmanifest文件