| 网站首页 | VB.Net实例分析 | .Net技术文摘 | 下载中心 | VB.Net书籍笔记 | .Net源码 | VBS脚本与组件调用 | Windows2008技术文摘 | 给我们留言 | 
最新公告:

  没有公告

您现在的位置: 乐博网 >> VB.Net实例分析 >> 网络编程 >> 实例分析正文
最新推荐 更多内容
VB.Net代理服务器的实例
VB.Net代理服务器的实例
作者:microsoft    来源:microsoft     更新时间:2009-8-6

代码如下:

Visual Basic
            ' Create a new request to the mentioned URL.                
            Dim myWebRequest As HttpWebRequest = CType(WebRequest.Create(http://www.lob.cn), HttpWebRequest)

                  ' Obtain the 'Proxy' of the  Default browser.  
                  Dim proxy as IWebProxy = CType(myWebRequest.Proxy, IWebProxy)
                  ' Print the Proxy Url to the console.
            If Not proxy Is Nothing Then
                Console.WriteLine("Proxy: {0}", proxy.GetProxy(myWebRequest.RequestUri))
            Else
                Console.WriteLine("Proxy is null; no proxy will be used")
            End If

            Dim myProxy As New WebProxy()

            Console.WriteLine(ControlChars.Cr + "Please enter the new Proxy Address that is to be set ")
            Console.WriteLine("(Example:http://www.ilu.com.cn:8080)")
            Dim proxyAddress As String  '更多.net源码教程 来自乐博网 lob.cn
            Try
                proxyAddress = Console.ReadLine()
                If proxyAddress.Length = 0 Then
                    myWebRequest.Proxy = myProxy
                Else
                    Console.WriteLine(ControlChars.Cr + "Please enter the Credentials (may not be needed)")
                    Console.WriteLine("Username:")
                    Dim username As String
                    username = Console.ReadLine()
                    Console.WriteLine(ControlChars.Cr + "Password:")
                    Dim password As String
                    password = Console.ReadLine()
                    ' Create a new Uri object.
                    Dim newUri As New Uri(proxyAddress)
                    ' Associate the newUri object to 'myProxy' object so that new myProxy settings can be set.
                    myProxy.Address = newUri
                    ' Create a NetworkCredential object and associate it with the Proxy property of request object.
                    myProxy.Credentials = New NetworkCredential(username, password)
                    myWebRequest.Proxy = myProxy
                End If
                Console.WriteLine(ControlChars.Cr + "The Address of the  new Proxy settings are {0}", myProxy.Address)
                Dim myWebResponse As HttpWebResponse = CType(myWebRequest.GetResponse(), HttpWebResponse)
         Catch 
      End try
  • 上一篇:

  • 下一篇:
  • 【字体: 】【打印此文】【关闭窗口
      相关文章:(只显示最新16条)
    没有相关实例分析

    | 设为首页 | 加入收藏 | 联系站长 | | 友情链接 | 版权申明 |
    乐博网欢迎各种媒体转载我们的原创作品[转载请注明出处];我们鼓励更多VB.Net开发者一起加入研究与探讨;如发现文章访问错误、内容错误或版权疑问、内容有违相关法律(如涉及政治、色情、反动或散布虚假有害信息)等情况,请及时向我们举报,我们将及时纠正!
    联系邮箱:Shiny#vip.qq.com (#替换为@) QQ交流群: 40797788 [闽ICP备05014267号]