本文介绍了如何使用C#代码设置代理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!







如何使用C#设置代理(地址和端口)代码。



非常感谢..

Hi !
.
.

How to set Proxy (Address and Port) with C# code .

Thanks lot ..

推荐答案


Dim ioDataStream As Stream
Dim lWebResponse As HttpWebResponse
Dim lWebRequest As HttpWebRequest

Try
    'Create the web request
    lWebRequest = WebRequest.Create("http://mywebpage.com")

    Dim proxyObject As New WebProxy("http://myproxy:8080/", True)
    proxyObject.Credentials = CredentialCache.DefaultNetworkCredentials
    lWebRequest.Proxy = proxyObject
    ' If required by the server, set the credentials.
    lWebRequest.Credentials = CredentialCache.DefaultNetworkCredentials
    'Attach to the response object
    lWebResponse = lWebRequest.GetResponse
    'Funnel the response into the stream reader...
    ioDataStream = lWebResponse.GetResponseStream
Catch ex As Exception
    'Handle exceptions here...

End Try


这篇关于如何使用C#代码设置代理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-22 18:30