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}");
            }
        }
    }
}
相关推荐
2501_9411481516 小时前
高并发搜索引擎Elasticsearch与Solr深度优化在互联网实践分享
java·开发语言·前端
专家大圣16 小时前
告别局域网束缚!飞牛云 NAS+cpolar 让远程管理更简单
开发语言·网络·内网穿透·cpolar
共享家952717 小时前
QT-界面优化(上)
开发语言·qt
熊猫钓鱼>_>17 小时前
从零开始构建RPG游戏战斗系统:实战心得与技术要点
开发语言·人工智能·经验分享·python·游戏·ai·qoder
FuckPatience17 小时前
C++ 常用类型写法和全称
开发语言·c++
q***R30817 小时前
Kotlin注解处理
android·开发语言·kotlin
lly20240617 小时前
C++ 数组
开发语言
csbysj202017 小时前
C 强制类型转换
开发语言
m0_6265352017 小时前
代码分析
开发语言·c#
q***37517 小时前
QoS质量配置
开发语言·智能路由器·php