惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Darknet – Hacking Tools, Hacker News & Cyber Security
V
Vulnerabilities – Threatpost
Cloudbric
Cloudbric
G
GRAHAM CLULEY
S
Securelist
Schneier on Security
Schneier on Security
Help Net Security
Help Net Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Project Zero
Project Zero
Spread Privacy
Spread Privacy
P
Privacy International News Feed
C
Cyber Attacks, Cyber Crime and Cyber Security
Cisco Talos Blog
Cisco Talos Blog
T
Tailwind CSS Blog
博客园_首页
有赞技术团队
有赞技术团队
Simon Willison's Weblog
Simon Willison's Weblog
Stack Overflow Blog
Stack Overflow Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Latest news
Latest news
T
Tor Project blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Attack and Defense Labs
Attack and Defense Labs
www.infosecurity-magazine.com
www.infosecurity-magazine.com
O
OpenAI News
J
Java Code Geeks
T
Tenable Blog
K
Kaspersky official blog
AWS News Blog
AWS News Blog
S
Security @ Cisco Blogs
The GitHub Blog
The GitHub Blog
T
Threatpost
月光博客
月光博客
H
Heimdal Security Blog
Security Latest
Security Latest
The Hacker News
The Hacker News
Y
Y Combinator Blog
A
Arctic Wolf
Apple Machine Learning Research
Apple Machine Learning Research
C
Cisco Blogs
美团技术团队
Microsoft Security Blog
Microsoft Security Blog
Hugging Face - Blog
Hugging Face - Blog
T
The Blog of Author Tim Ferriss
C
CERT Recently Published Vulnerability Notes
D
Docker
Google Online Security Blog
Google Online Security Blog
D
DataBreaches.Net
V
Visual Studio Blog
H
Help Net Security

博客园 - Gofficer

决战紫禁之巅 为学 C#网页自动登录和提交POST信息的多种方法 一个C#写的调用外部进程类 快速实现在Windows应用程序中支持拖拽的TreeView控件(C#) PPT转图片 开发人员,敢问路在何方? C# 实现注销、关机、重启电脑功能 ultraGrid 控件中,实现单元格内容换行显示 如何用一条sql取得第10到第20条的记录? 用Sandcastle一键生成CHM帮助文档 实现服务器端与客户端对话 C#中访问WEB页面 自定义Ping方法 HTTP请求和应答 Socket套接字实现服务器端连接 Socket套接字实现客户端连接 启动和停止本地系统进程 异常处理
使用代理服务器
Gofficer · 2007-08-24 · via 博客园 - Gofficer

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
// 添加新的命名空间。
using System.Net;
using System.IO;

namespace Proxy
{
    
/// <summary>
    
/// 使用代理服务器。
    
/// </summary>

    public class Form1 : System.Windows.Forms.Form
    
{
        
private System.Windows.Forms.Button button1;
        
private System.Windows.Forms.Button button2;
        
private System.Windows.Forms.RichTextBox richTextBox1;
        
/// <summary>
        
/// 必需的设计器变量。
        
/// </summary>

        private System.ComponentModel.Container components = null;

        
public Form1()
        
{
            
//
            
// Windows 窗体设计器支持所必需的
            
//
            InitializeComponent();

            
//
            
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
            
//
        }


        
/// <summary>
        
/// 清理所有正在使用的资源。
        
/// </summary>

        protected override void Dispose( bool disposing )
        
{
            
if( disposing )
            
{
                
if (components != null)
                
{
                    components.Dispose();
                }

            }

            
base.Dispose( disposing );
        }


        
Windows Form Designer generated code

        
/// <summary>
        
/// 应用程序的主入口点。
        
/// </summary>

        [STAThread]
        
static void Main()
        
{
            Application.Run(
new Form1());
        }

        
// 定义私有变量。
        public HttpWebRequest req;
        
public HttpWebResponse res;
        
public WebProxy proxy;
        
public Stream s;
        
public StreamReader r;
        
// 使用默认代理。
        private void button1_Click(object sender, System.EventArgs e)
        
{
            button1.Enabled 
= false;
            proxy 
= new WebProxy("http://127.0.0.1:8888"true);
            GlobalProxySelection.Select 
= proxy;
            req 
= (HttpWebRequest)WebRequest.Create("http://www.microsoft.com");
            res 
= (HttpWebResponse)req.GetResponse();
            s 
= res.GetResponseStream();
            r 
= new StreamReader(s);
            richTextBox1.Text 
= r.ReadToEnd();
            r.Close();
            s.Close();
            res.Close();
            button1.Enabled 
= true;
        }

        
// 使用专门代理。
        private void button2_Click(object sender, System.EventArgs e)
        
{
            button2.Enabled 
= false;
            proxy 
= new WebProxy("http://127.0.0.1:8887"true);
            req 
= (HttpWebRequest)WebRequest.Create("http://www.microsoft.com");
            req.Proxy 
= proxy;
            res 
= (HttpWebResponse)req.GetResponse();
            s 
= res.GetResponseStream();
            r 
= new StreamReader(s);
            richTextBox1.Text 
= r.ReadToEnd();
            r.Close();
            s.Close();
            res.Close();
            button2.Enabled 
= true;
        }

    }

}