簡體   English   中英

無法從WinRT連接到遠程服務器

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

我正在創建一個基本上只需要將一段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;

    }

我發布的服務器不是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"}

我的應用程序具有Internet客戶端功能。 我可以通過其他商店應用訪問我的本地網絡和互聯網。 我可以在firefox中訪問資源獲得正確的行為。 我沒有啟用防火牆,也沒有阻止這些端口的防病毒軟件

什么可能導致這個模糊的錯誤? 我該如何解決?

要訪問LAN,您必須在應用程序清單中聲明Private Network功能。 請注意,這與Internet功能不同。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM