a couple of problems

Feb 11 2008 10:38 AM

I'm actually writing a larger program and it was having issues, so I just wrote this to track them down. here's the code:

 
 
*****CODE*****

Imports System

Imports System.Net

Imports System.IO

Public Class Form1

    Private request As HttpWebRequest

    Private response As HttpWebResponse

    Dim stri As String

 

 

   

    Private Sub btnWebpageTest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnWebpageTest.Click

        Me.request = WebRequest.Create(txtwebpage.Text)

        Me.request.Timeout = 5000

        Try

            Me.response = Me.request.GetResponse()

        Catch ex As Exception

            lblweb.ForeColor = Color.Red

            lblweb.Text = "Down"

            stri = ex.ToString

            txterror.Text = stri

            GoTo b

        End Try

        lblweb.ForeColor = Color.Green

        lblweb.Text = "UP"

b:

    End Sub

End Class

*****End Code*****

 

The problems I'm having are:

 

1. My compter is on a network running a proxy and after about 30 seconds, if I try to check if a webpage is up, I'm getting:

System.Net.WebException: The remote server returned an error: (407) Proxy Authentication Required.
   at System.Net.HttpWebRequest.GetResponse()
   at WindowsApplication1.Form1.btnwebpage_Click(Object sender, EventArgs e)
 

How can I get around this or set up proxy authentication within the program?

 

2.  the main websites I need to check have an invalid security certificate installed, so if I try to check them, I get:

System.Net.WebException: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel. ---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.
   at System.Net.Security.SslState.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, Exception exception)

How can I either get around this or apply this error to a catch statement so that I can return a boolean of true?

 

Any help would be greatly appreciated