|
-
Apr 27th, 2004, 03:36 AM
#1
Thread Starter
Fanatic Member
Webproxy problem.
Hi.
I have asked this once before, and I did get some replies, but unfortunatly none that worked.
How to use webproxy and webrequest?
I just get a timeout exception.
I have also tried to set the proxy manual. Then I don't get the timeout, but "an unexpected error occured during recive".
I found this sample on MSDN
VB Code:
Dim sURL As String
sURL = "http://www.microsoft.com"
Dim wrGETURL As WebRequest
wrGETURL = WebRequest.Create(sURL)
wrGETURL.Proxy = WebProxy.GetDefaultProxy()
Dim objStream As Stream
objStream = wrGETURL.GetResponse.GetResponseStream()
Dim objReader As New StreamReader(objStream)
Dim sLine As String = ""
Dim i As Integer = 0
Do While Not sLine Is Nothing
i += 1
sLine = objReader.ReadLine
If Not sLine Is Nothing Then
Console.WriteLine("{0}:{1}", i, sLine)
End If
Loop
Console.ReadLine()
I figured, "hey, ms made it, so it must work...". Well, it didn't. At least not for me.
Here's some screenshots of my proxy settings in IE.
Can anyone help me with this?
I wish I could think of something witty to put in my sig...
...Currently using VS2013...
-
Apr 28th, 2004, 08:19 AM
#2
Thread Starter
Fanatic Member
Bump
I wish I could think of something witty to put in my sig...
...Currently using VS2013...
-
May 10th, 2004, 04:13 AM
#3
Thread Starter
Fanatic Member
Final Bump
I wish I could think of something witty to put in my sig...
...Currently using VS2013...
-
May 10th, 2004, 05:43 AM
#4
Fanatic Member
from msdn
code is from msdn so it should work
VB Code:
' Create a new request to the mentioned URL.
Dim myWebRequest As WebRequest = WebRequest.Create("http://www.contoso.com")
Dim myProxy As New WebProxy()
' Obtain the Proxy Prperty of the Default browser.
myProxy = CType(myWebRequest.Proxy, WebProxy)
' Print myProxy address to the console.
Console.WriteLine(ControlChars.Cr + "The actual default Proxy settings are {0}", myProxy.Address)
Try
Console.WriteLine(ControlChars.Cr + "Please enter the new Proxy Address to be set ")
Console.WriteLine("The format of the address should be [url]http://proxyUriAddress:portaddress[/url]")
Console.WriteLine("Example:[url]http://moon.proxy.com:8080[/url]")
Dim proxyAddress As String
proxyAddress = Console.ReadLine()
If proxyAddress.Length = 0 Then
myWebRequest.Proxy = myProxy
Else
Console.WriteLine(ControlChars.Cr + "Please enter the Credentials")
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 new Uri object to the myProxy object.
myProxy.Address = newUri
' Create a NetworkCredential object and is assign to the Credentials property of the Proxy 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 WebResponse = myWebRequest.GetResponse()
' Print the HTML contents of the page to the console.
Dim streamResponse As Stream = myWebResponse.GetResponseStream()
Dim streamRead As New StreamReader(streamResponse)
Dim readBuff(256) As [Char]
Dim count As Integer = streamRead.Read(readBuff, 0, 256)
Console.WriteLine(ControlChars.Cr + "The contents of the Html pages are :")
While count > 0
Dim outputData As New [String](readBuff, 0, count)
Console.Write(outputData)
count = streamRead.Read(readBuff, 0, 256)
End While
' Close the Stream object.
streamResponse.Close()
streamRead.Close()
' Release the HttpWebResponse Resource.
myWebResponse.Close()
Console.WriteLine(ControlChars.Cr + "Press any key to continue.........")
Console.Read()
Catch e As UriFormatException
Console.WriteLine(ControlChars.Cr + "{0}", e.Message)
Console.WriteLine(ControlChars.Cr + "The format of the myProxy address you entered is invalid")
End Try
I am curretly building a defect management system for software and web developers,
If you wana try it out (beta test) and keep it for free just send me a message
-
May 10th, 2004, 06:03 AM
#5
Thread Starter
Fanatic Member
Hi.
Thanks for the answer. Unfortunatly it didn't work.
My conclusion is, that there must be some security thing blocking my way.
I have tried many samples now, and none of them work, so I don't think there's anything wrong with the samples.
It must be some firewall setting...So I guess I just have to live with it.
But thanks for your time anyway.
I wish I could think of something witty to put in my sig...
...Currently using VS2013...
-
May 10th, 2004, 06:09 AM
#6
Fanatic Member
what proxy and firewall client are you using ?
Ive used proxy code before when using isa server and it worked fine....
I am curretly building a defect management system for software and web developers,
If you wana try it out (beta test) and keep it for free just send me a message
-
May 10th, 2004, 07:13 AM
#7
Thread Starter
Fanatic Member
Hi.
I really don't know, actually. I'm just one of the small guys in the company, and I usually only make small test app's. Nothing that ever get's published. So unfortunatly I have no insigth or access to any of the servers. All IT is handled by our HQ, which is located in another country. And company policy is so stiff, that I have no chance in h**l to make them change anything. Not with this small app.
This is the first time that I have tried to access the Internet from my workstation, so I thought that maybe I was doing something wrong. I have no problem using my own DSL connection at home.
It was supposed to collect some data from various sites, but the user can just as well input the data manually.
But I guess, they just have to miss this feature from the app.
I don't believe it was that important. More like a "nice to have" feature. I will just have to tell them, it can't be done, with policy being as it is.
But I still wish to thank you for your time.
I wish I could think of something witty to put in my sig...
...Currently using VS2013...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|