0
这段代码被写入以向服务发送请求并接收简单的json响应,但服务的服务器日志显示它正在被请求两次,延迟1秒。我无法弄清楚为什么这段代码提出请求两次,请指导我如果有一些配置丢失。它为什么要发送两次请求
string StrUrl = @"http://www.myapp.com/Tracker.json";
Uri uri1 = new Uri(StrUrl);
HttpWebRequest webRequest1 = (HttpWebRequest)HttpWebRequest.Create(uri1);
webRequest1.ServicePoint.ConnectionLimit = 1;
webRequest1.Timeout = 50000;
webRequest1.ReadWriteTimeout = 50000
webRequest1.PreAuthenticate = false;
webRequest1.Proxy = null;
webRequest1.CookieContainer = cookieJar;
webRequest1.Method = "POST";
webRequest1.KeepAlive = false;
WebResponse response1 = webRequest1.GetResponse();
StreamReader streamReader1 = new StreamReader(response1.GetResponseStream());
String responseData1 = streamReader1.ReadToEnd();
这些可能也有类似的问题
Why my Http client making 2 requests when I specify credentials?
看起来不错。也许你打电话给这个功能两次? –
检查你的代码,看看你是否调用两次函数。 – user1666620
我已经在调试器中测试了带有断点的代码。它只运行一次 – Saifee