C# 代理IP的winform

C# 代理IP的winform

python 复制代码
using System;
using System.Net;
using System.Windows.Forms;
 
namespace ProxyIPWinForms
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }
 
        private void btnSendRequest_Click(object sender, EventArgs e)
        {
            string proxyAddress = $"http://{txtProxyIP.Text}:{txtProxyPort.Text}";
            WebProxy proxy = new WebProxy(proxyAddress);
 
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://example.com");
            request.Proxy = proxy;
 
            try
            {
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                MessageBox.Show($"Status Code: {response.StatusCode}");
                response.Close();
            }
            catch (WebException ex)
            {
                MessageBox.Show($"Error: {ex.Message}");
            }
        }
    }
}
相关推荐
追逐时光者4 小时前
一个致力于为 C# 程序员提供更佳的编码体验和效率的 Visual Studio 扩展插件
后端·c#·visual studio
molaifeng5 小时前
Go 语言如何实现高性能网络 I/O:Netpoller 模型揭秘
开发语言·网络·golang
崇山峻岭之间5 小时前
Matlab学习记录33
开发语言·学习·matlab
Evand J5 小时前
【2026课题推荐】DOA定位——MUSIC算法进行多传感器协同目标定位。附MATLAB例程运行结果
开发语言·算法·matlab
jllllyuz6 小时前
基于MATLAB的二维波场模拟程序(含PML边界条件)
开发语言·matlab
忆锦紫6 小时前
图像增强算法:Gamma映射算法及MATLAB实现
开发语言·算法·matlab
SunflowerCoder6 小时前
EF Core + PostgreSQL 配置表设计踩坑记录:从 23505 到 ChangeTracker 冲突
数据库·postgresql·c#·efcore
亲爱的非洲野猪7 小时前
Java锁机制八股文
java·开发语言
LawrenceLan7 小时前
Flutter 零基础入门(十二):枚举(enum)与状态管理的第一步
开发语言·前端·flutter·dart
charlie1145141918 小时前
从 0 开始的机器学习——NumPy 线性代数部分
开发语言·人工智能·学习·线性代数·算法·机器学习·numpy