Tag: 代理

测试代理设置的首选方法是什么?

我正在处理的程序中的互联网连接有很多麻烦,而这一切似乎都是由代理设置的某些问题产生的。 此时的大多数问题都是固定的,但我现在遇到的问题是我的代理设置测试方法会让一些用户等待很长时间。 这是我做的: System.Net.WebClient webClnt = new System.Net.WebClient(); webClnt.Proxy = proxy; webClnt.Credentials = proxy.Credentials; byte[] tempBytes; try { tempBytes = webClnt.DownloadData(url.Address); } catch { //Invalid proxy settings //Code to handle the exception goes here } 这是我发现测试代理设置是否正确的唯一方法。 我尝试对我们的Web服务进行Web服务调用,但在拨打电话时不需要代理设置。 即使我有伪造的代理设置,它也会工作。 但是,上面的方法没有我可以设置的超时成员,我可以使用DownloadData而不是DownloadDataAsync,因为我需要等待方法完成,以便在继续之前我可以知道设置是否正确在该计划中。 任何关于更好的方法或解决方法的建议都值得赞赏。 麦克风 编辑:我尝试了其他的东西,但没有运气。 我使用DownloadDataAsync方法在一个单独的线程中下载数据,该线程在完成后引发WebClient的DownloadDataCompleted事件。 当我等待事件被调用时,我有一个循环:while(DateTime.Now <downloadStart.AddMinutes(timeout)&&!TestIsDone){}当调用事件时,DownloadDataCompleted事件将TestIsDone成员设置为true。 这里的问题是如果代理设置不好,则永远不会调用Event,不会抛出异常,程序会在继续之前等待整个超时时间。 以下是此方法的代码: public static bool TestProxy(System.Net.WebProxy proxy) { ProxySettingsTestDone = […]

服务器提交了协议违规。 Section =使用tor代理时的ResponseStatusLine

我正在尝试使用我的asp.net应用程序使用tor代理发送httpwebrequest,并在调用webresponse.GetResponse()方法时收到此错误消息: 服务器提交了协议违规。 第= ResponseStatusLine 我尝试在网上搜索解决方案,我找到了3个主要解决方案: 添加到Web.config。 ` 添加以下行: webRequest.ProtocolVersion = HttpVersion.Version10; 到代码。 添加行request.ServicePoint.Expect100Continue = false; 到代码。 列出的每个解决方案都没有改变错误消息。 这是请求代码: WebRequest.DefaultWebProxy = new WebRequest(“127.0.0.1:9051”); HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url); webRequest.CookieContainer = new CookieContainer(); webRequest.ProtocolVersion = HttpVersion.Version10; webRequest.KeepAlive = false; webRequest.Method = “GET”; webRequest.ContentType = “application/x-www-form-urlencoded”; webRequest.Accept = “text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8”; webRequest.UserAgent = “Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.19 (KHTML, like Gecko) […]

实现http / https和socks代理的库

我寻找实现http / https和socks-proxy的库。 我试着谷歌它,但我发现的唯一的类/ libs实现了袜子没有袜子ssl或ssl。 也许任何人都有这个问题的解决方案,或者你可以给我一个建议如何自己实现它也有帮助。 Thx提前。 PS 似乎这个琐碎的技术.NET只有商业解决方案我不能相信它!?

使用Selenium代理

在过去的两天里,我一直在尝试使用Selenium的代理,但这不是问题。 问题是代理是私有的意味着它需要身份validation才能使用它(用户名和密码),但我无法弄清楚如何做到这一点。 我正在使用Firefox驱动程序,其配置文件如下: FirefoxProfile firefoxProfile = new FirefoxProfile(); firefoxProfile.SetPreference(“network.proxy.type”, 1); firefoxProfile.SetPreference(“network.proxy.http”, “23.95.115.87”); firefoxProfile.SetPreference(“network.proxy.http_port”, 80); var driver = new FirefoxDriver(firefoxProfile); driver.Navigate().GoToUrl(“http://ipchicken.com”); 我想它会询问我的用户名和密码(在对话框中)但没有任何反应,它只是导航到网页,并显示我自己的IP。 我找不到任何真的这个,有什么帮助吗? 非常感谢。

检查特定网站上的大代理列表的最快方法是什么?

我有一个很大的代理服务器列表(txt文件,格式= ip:每行的端口),并编写下面的代码来检查它们: public static void MyChecker() { string[] lines = File.ReadAllLines(txtProxyListPath.Text); List list_lines = new List(lines); List list_lines_RemovedDup = new List(); HashSet HS = new HashSet(); int Duplicate_Count = 0; int badProxy = 0; int CheckedCount = 0; foreach (string line in list_lines) { string[] line_char = line.Split(‘:’); string ip = line_char[0]; string port = […]

如何关闭Web服务调用的持久连接

从我的WinForms应用程序,我必须调用Web服务,我正在使用Web引用。 到目前为止没有问题,但现在我有一个客户端使用负载平衡器后面的代理背后的软件。 Web服务调用很顺利,但两分钟后它们就失败了。 我们可以通过反复调用间隔小于两分钟的Web服务来解决这个问题。 我发现负载均衡器在没有使用两分钟时会断开tcp会话,看起来这就是我们的情况,软件无法恢复。 如何告知gerenated Web引用为每个Web服务调用使用新的tcp连接?

用户IP地址,使用代理还是不使用代理

请参阅以下代码: private string GetUserIPAddress() { string User_IPAddress = string.Empty; string User_IPAddressRange = Request.ServerVariables[“HTTP_X_FORWARDED_FOR”]; if (string.IsNullOrEmpty(User_IPAddressRange))//without Proxy detection { User_IPAddress = Request.ServerVariables[“REMOTE_ADDR”]; //or //Client_IPAddress = Request.UserHostAddress; //or //User_IPAddress = Request.ServerVariables[“REMOTE_HOST”]; } else////with Proxy detection { string[] splitter = { “,” }; string[] IP_Array = User_IPAddressRange.Split(splitter, System.StringSplitOptions.None); int LatestItem = IP_Array.Length – 1; User_IPAddress = IP_Array[LatestItem – […]

Asp.Net – CacheUpdateCallback缓存的绝对到期时间是否小于20秒?

我有一个下面详细介绍的测试工具。 这在页面上有两个标签,这些标签在page_load中设置,由于updatepanel和timer,每秒都会被触发。 Label1设置为存储在Cache中的日期时间值。 Label2设置为当前日期时间。 从现在开始,缓存设置的绝对有效期为5秒,缓存上有一个更新回调,用于重新设置日期时间并使其有效5秒。 我遇到的问题是我每隔20秒就会看到缓存更新,而不是像我期望的那样每隔5秒更新一次。 如果我将时间设置为30秒,则每40次更新一次。 这似乎表明缓存只会每20秒到期一次。 有谁知道减少这个时间的方法? 如果我只是在5秒的时间内插入缓存并且没有回调,那么它就像我期望的那样工作并且每5秒被移除一次。 ASPX: Cache Test 代码背后: using System; using System.Web; using System.Web.Caching; using System.Web.UI; using System.Web.UI.WebControls; public partial class CacheTest : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { DateTime CachedDateTime = (DateTime)(Cache[“DateTime”] ?? DateTime.MinValue); if (CachedDateTime == DateTime.MinValue) { CachedDateTime = System.DateTime.Now; Cache.Insert(“DateTime”, CachedDateTime, null, […]

调用Web服务时“请求失败并显示空响应”

从aspx页面调用托管在服务器中的Web服务时,会收到类似“请求失败且响应为空”的错误。 我页面中的代码 try { HttpWebRequest request1 = (HttpWebRequest)WebRequest.Create(“https://login.erp.com/rodeprovisioning/provisioning.asmx”); request1.Accept = “text/xml”; request1.Method = “POST”; WebProxy proxyObject = new System.Net.WebProxy(“http://10.0.0.1:8080/”, true); request1.Proxy.Credentials = CredentialCache.DefaultCredentials; string sReturnValue = null; if (string.IsNullOrEmpty(Session[“Test”])) { sReturnValue = callservice(); if (sReturnValue == “Success”) { ErrorLabel.Text = sReturnValue; Session[“Test”] = “True”; } else { ErrorLabel.Text = sReturnValue; } } } catch (Exception […]

如何使用Watin IE处理Windows安全警报对话框

我正在尝试使用WatIN IE自动化网站。 由于网站在几次请求后禁止了ip。因此,当ip被禁止时,我设置了一个bool ipbanned = true。 在那种情况下,我希望改变IP。 SetProxy方法使用端口成功更改ip地址。 但在下一个要求我得到这个屏幕: – 注意: – 第一个红色条带显示IP地址,第二个红色条带显示服务器名称 如何在程序中设置此对话框中的用户名和密码,以便用户无法看到此框并且设置正确 以下是我使用的代码段: – private void Start_Thread() { Thread pop = new Thread(populate); pop.SetApartmentState(ApartmentState.STA); pop.Start(); } bool ipbanned=false; private void populate() { if(ipbanned) SetProxy(proxies[0]); ///I wish to handle the dialog box here. WatiN.Core.Settings.MakeNewIeInstanceVisible = false; WatiN.Core.Settings.Instance.AutoMoveMousePointerToTopLeft = false; using (IE browser = new […]