vb.net代理服务器 [英] vb.net Proxy server
本文介绍了vb.net代理服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们的服务器具有代理,要使用Internet,我们应该输入用户名和密码才能使用Internet.
如何编写程序以通过vb.net中的代理服务器?
我的代码有什么问题??
错误407 !!!
:(
our server has proxy, and for using internet we should enter username and password to use internet.
how to write a program to pass proxy server in vb.net?
what is problem with my code???
error 407!!!
:(
Dim sResult As String
Dim objResponse As WebResponse
Dim objRequest As WebRequest = System.Net.HttpWebRequest.Create(URL)
oProxy.Credentials = New NetworkCredential(UserName, PassWord, Domain)
objRequest.Proxy = oProxy
objRequest.Method = "GET"
objRequest.Timeout = 120000 '' 20 sec.
objResponse = objRequest.GetResponse
Dim sr As System.IO.StreamReader = New StreamReader(objResponse.GetResponseStream(), System.Text.Encoding.UTF7)
sResult = sr.ReadToEnd()
sr.Close()
推荐答案
查看该错误表明它是代理身份验证错误.
googling that error shows that its a proxy authentication error.
请看一下此代码项目的讨论:
http://www.codeproject.com/Messages/3000519/Re-WebRequest-GetResponse-equals-error-407-Proxy-A.aspx [
Take a look at this codeproject discussion:
http://www.codeproject.com/Messages/3000519/Re-WebRequest-GetResponse-equals-error-407-Proxy-A.aspx[^]
try using
poProxy.Credentials = CredentialCache.DefaultCredentials
代替
instead of
oProxy.Credentials = New NetworkCredential(UserName, PassWord, Domain)
这篇关于vb.net代理服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文