SmashTech

Did you buy a harmonica?

Using a Web Proxy in .Net 2003

.Net is kind enough to pull your current Internet Explorer proxy settings by default.  But it leaves out one important option – the ‘Use Windows integrated authentication’ checkbox.  If your proxy server requires NTLM authentication, and you’re relying on this feature of IE for it, then your .Net 1.1 apps will not work.  Any web or web service requests will return a ‘Proxy authentication required’ error.

There are 2 options at this point.  You can tell your web request to completely ignore proxy settings and access the address directly:

webService.Proxy = System.Net.GlobalProxySelection.GetEmptyWebProxy

Or you can specify your own proxy server and credentials:

Dim authTest As New System.Net.NetworkCredential(“username”, “password”)
Dim proxTest As New System.Net.WebProxy(“http://192.168.0.4:3128″)
proxTest.Credentials = authTest
webService.Proxy = proxTest

I haven’t found any way (yet) with .Net 1.1 to have it use the credentials of the currently logged in user.

Edit: Nevermind, I’m an idiot.   You can use System.Net.CredentialCache.DefaultCredentials for the security settings of the current user.

Adding Dynamic Controls with VB.Net

The following code shows how to dynamically add a control to a form in VB.Net.  In this case, a multiline textbox is added, some settings for ScrollBars and CharacterCasing are adjusted, and the textbox is set to call the MLTextbox_GotFocus function when the control receives focus

 

Dim dynText As New TextBox
With dynText
    .Name = "textWhatever"
    .Top = 40
    .Left = 40
    .Width = 80
    .Height = 60
    .Multiline = True
    .ScrollBars = ScrollBars.Vertical
    .CharacterCasing = CharacterCasing.Upper
End With
formMain.Controls.Add(dynText)
AddHandler dynText.Enter, AddressOf MLTextbox_GotFocus