使用脚本任务中的Webrequest来消耗Rest Service
我收到以下错误
原本希望保持连接状态的连接已被关闭。服务器
我正在For Each循环容器中调用rest服务。它是第一次运行,但以后没有执行。
搜索堆栈溢出,我遇到了以下设置,可以帮助其他人,但不能帮助我
ServicePointManager.Expect100Continue = false;
ServicePointManager.DefaultConnectionLimit = 100;
ServicePointManager.MaxServicePointIdleTime = 5000;
我想这是因为KeepAlive属性设置为true,但是我看不到更改它的方法,也看不到可以更改的it isn't a property
HttpWebRequest req = WebRequest.Create("https://www.server.com/api/stuff") as HttpWebRequest;
req.KeepAlive = false;
HttpWebResponse response = (HttpWebResponse)req.GetResponse();
或替代
internal class MyWebClient : WebClient { override WebRequest GetWebRequest(Uri address) { HttpWebRequest req = (HttpWebRequest)base.GetWebRequest(address); req.KeepAlive = false; return req; } }
您的WebRequest
以访问其他隐藏或抽象的属性!