Willie007

Hi,

i want ot use a webbrowser, but have to specify proxy server settings such as the name and port.

Is it possible to specify this with the webbrowser.navigate command

I know how to use the authentication data....

Code Snippet

If UserID.Length > 0 OrElse Password.Length > 0 Then

Dim Header As String = "Authorization: Basic " & UserID & ":" & Password

Dim i As Integer

Dim B(Header.Length) As Byte

For i = 0 To Header.Length - 1

Dim c As Char = Header.Substring(i, 1)

B(i) = System.Convert.ToByte(c)

Next

Dim header64 As String = System.Convert.ToBase64String(B)

WebBrowser.Navigate2(Url, "", Nothing, Header)

Else

WebBrowser.Navigate2(Url)

End If



Re: Windows Forms General webbrowser how to: proxy server settings

Yu Guo – MSFT

Hi, Willie007,

Based on my understanding, you want to know if it is possible to send the proxy information with Navigate method, don't you

I think you are now using the ActiveX webbrowser in your project, right

It is possible for this control to post the proxy infomations with Navigate method.

You can use

Code Snippet
Me.WebBrowser.Navigate(URL, Nothing, Nothing, Nothing, Header)

And here is an article about it,

http://support.microsoft.com/kb/q172998/

Althrough it's in VB, it still works for this control in VB.net.

Hope this helps,

Regards






Re: Windows Forms General webbrowser how to: proxy server settings

Willie007

Until now I only was able to find information for the header about username and password.

i found out to use the:

Proxy-Authorization = "Proxy-Authorization" ":" credentials

But I can not find the credentials details....

Anyone a idea





Re: Windows Forms General webbrowser how to: proxy server settings

Yu Guo – MSFT

Hi, Willie007,

Sorry for misunderstanding you requests.

As far as I know, you cannot set the proxy server name and port through header information.

And in the Proxy-Authorization field, you should add the authentication information such as user name and password.

For example, "Proxy-Authorization: Basic wWdkd2284lssdj\r\n".

Here "wWdkd2284lssdj" is Base64 encrypted "username: password".

Unlike Authorization filed, it's only for the next proxy server.

http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html

And if you want to set proxy server and port programmatically,

you can try the codes in the following url

http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=664360&SiteID=1

Hope this helps,

Regards






Re: Windows Forms General webbrowser how to: proxy server settings

Willie007

thanks,

this helped me to find this:

Code Block

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

RefreshIESettings("10.56.57.20:40")

End Sub

Public Structure Struct_INTERNET_PROXY_INFO

Public dwAccessType As Integer

Public proxy As IntPtr

Public proxyBypass As IntPtr

End Structure

<Runtime.InteropServices.DllImport("wininet.dll", SetLastError:=True)> _

Private Shared Function InternetSetOption(ByVal hInternet As IntPtr, ByVal dwOption As Integer, ByVal lpBuffer As IntPtr, ByVal lpdwBufferLength As Integer) As Boolean

End Function

Private Sub RefreshIESettings(ByVal strProxy As String)

Const INTERNET_OPTION_PROXY As Integer = 38

Const INTERNET_OPEN_TYPE_PROXY As Integer = 3

Dim struct_IPI As Struct_INTERNET_PROXY_INFO

' Filling in structure

struct_IPI.dwAccessType = INTERNET_OPEN_TYPE_PROXY

struct_IPI.proxy = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(strProxy)

struct_IPI.proxyBypass = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi("local")

' Allocating memory

Dim intptrStruct As IntPtr = System.Runtime.InteropServices.Marshal.AllocCoTaskMem(System.Runtime.InteropServices.Marshal.SizeOf(struct_IPI))

' Converting structure to IntPtr

System.Runtime.InteropServices.Marshal.StructureToPtr(struct_IPI, intptrStruct, True)

Dim iReturn As Boolean = InternetSetOption(IntPtr.Zero, INTERNET_OPTION_PROXY, intptrStruct, System.Runtime.InteropServices.Marshal.SizeOf(struct_IPI))

End Sub