.net - 如何通过代理发送 WebRequest?

标签 .net proxy httpwebrequest port

下面的代码需要怎么修改才能发送WebRequest通过指定的 proxy serverport number ?

Dim Request As HttpWebRequest = WebRequest.Create(url)
Request.Method = "POST"
Request.ContentType = "application/x-www-form-urlencoded"
Using writer As StreamWriter = New StreamWriter(Request.GetRequestStream())
    writer.Write(params)
End Using

最佳答案

使用 MSDN 中的此代码:

Dim myProxy As New WebProxy()
myProxy.Address = New Uri("proxyAddress")
myProxy.Credentials = New NetworkCredential("username", "password")
myWebRequest.Proxy = myProxy

关于.net - 如何通过代理发送 WebRequest?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13447495/

相关文章:

时间:2019-03-17 标签:c#web浏览器cookieshttpwebrequest

c# - 具体 .Net 类的依赖注入(inject)

c# - 在不使用 fiddler 的情况下将 HttpWebRequest 视为 GetResponse 之前的字符串

c# - 支持的 API 测试的认证测试错误

python - 多处理在进程之间共享不可序列化的对象

javascript - 如何在 webpack 中应用 createProxyMiddleware?

用于 http 的 Perl tcp_proxy

android - 如何通过我的 Android 应用程序对网络服务的用户进行身份验证?

.net - 关于正确使用数据表和数据集的困惑

.net - 如何以编程方式检查 oracle 版本