【发布时间】:2014-01-13 20:15:47
【问题描述】:
我在 VS 2012 目标 .NET 4.0 中使用 C# 和 winforms 开发了一个桌面应用程序。我正在使用 RestSharp 进行 API 通信,以下代码可以正常工作。
private RestClient client = new RestClient(Constants.BASE_URL);
var request = new RestRequest("venue/login", Method.POST);
request.AddParameter("email", email);
request.AddParameter("password", password);
IRestResponse<LoginResponse> response = client.Execute<LoginResponse>(request);
if (response.StatusCode.Equals(HttpStatusCode.OK))
我正在尝试使用 C#、WPF 和目标 .NET 4.0 在 VS 2010 中实现相同的应用程序。但是使用上面相同的代码IRestResponse<LoginResponse> response = client.Execute<LoginResponse>(request); 不会返回任何结果。它只是挂起。我对这两个项目都使用了 RestSharp 版本 104.4.0.0。可能是什么问题?
编辑:nginx 配置
server{
listen 80;
server_name api.xyz.com;
access_log /var/log/nginx/node.access.log;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://node;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
注意:如果我提供 BASEURL localhost/api(开发版),它可以工作。它不能在生产中工作 (api.xyz.com)。
【问题讨论】:
-
是否有代理服务器在起作用?
-
@jessehouwing 我将 nginx 与节点一起使用。使用 nginx 配置更新答案。但同样的 API 在 VS 2012 中也可以使用。
标签: c# .net wpf visual-studio-2010 restsharp