2016-06-10 37 views
1

我使用Nancyfx作为我的宁静api服务器。在Windows中,我使用ASP.NET的HOSTING MODE中的Nancyfx,在我的应用程序中所有工作都正常。但是,当我尝试使用Linux服务器,应用程序粉碎,因为我在这里使用下面Nancy selfhosting与Mono的Ubuntu的错误

HttpClient client = new HttpClient(); 
HttpResponseMessage response = await client.GetAsync("http://ipaddress:1234/api/info"); 
response.EnsureSuccessStatusCode(); 
string responseBody = await response.Content.ReadAsStringAsync(); 

这段代码异常,如下

型“System.Net.Http.HttpRequestException”的例外在System.Net.Http.dll发生 但在用户代码中没有处理

其他信息:500(内部服务器错误)

但是当我使用chrome来接收内容时,似乎工作正常。

HEADERS Content-Type:application/json; charset = utf-8 Date:2016 Jun 10 17:35:31 + 51s Keep-Alive:timeout = 15,max = 100 Link:;为rel = “application/xml进行” 服务器:单声道HTTPAPI/1.0传输编码:分块各不相同:接受

有什么错我的代码或Nancyfx selfhosting模式?

谢谢!

回答

1

好吧,我知道这里发生了什么。这是因为Windows10中的UWP应用程序无法连接到本地IP地址,如127.0.0.1!现在一切都很好。