私はVisual Studio 2015 Community EditionとVisual Basicを使って簡単なWebブラウザを作っています。私は以下のコードを追加しました。私のブラウザは動作しますが、私の問題はHTTPSプロトコルリンクでしか動作しないように見えることです。これはhttpが自動的にエラーをスローしてエラーハンドラが実行され、httpsプレフィックスでウェブサイトを再試行するためです。しかし、私はそのエラーが何であるか、それを修正する方法がわからない...助けることができる?私のウェブブラウザはhttpsリンクでのみ動作しますか?
CODE:ちょうど "公共のサブGoButton_clicked" 後のビットに焦点を当て、最初のビットを心配しないでください
Public Class Form1
'One button for go. Other for settings -incognito, history, homepage????
'Window button actions
Private Sub Green_Click(sender As Object, e As EventArgs) Handles Green.Click
Me.WindowState = FormWindowState.Maximized
End Sub
Private Sub Yellow_Click(sender As Object, e As EventArgs) Handles Yellow.Click
Me.WindowState = FormWindowState.Minimized
End Sub
Private Sub Red_Click(sender As Object, e As EventArgs) Handles Red.Click
Me.Close()
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
TitleText.Parent = Grey
TitleText.BackColor = Color.Transparent
TitleTextDivider.Parent = Grey
TitleTextDivider.BackColor = Color.Transparent
VersionText.Parent = Grey
VersionText.BackColor = Color.Transparent
End Sub
Public Sub GoButton_Click(sender As Object, e As EventArgs) Handles GoButton.Click
'Add checking blacklist and adding link to history file here later. Use separate subs and call them here for better organisation.
Dim Input As String = TextBox1.Text
'Prefix with http and www
Input = "http://www." + Input
'Convert to Uri
Dim Url As Uri = New Uri(Input)
'Set as url
WebBrowser1.Url = Url
'Refresh
WebBrowser1.Refresh()
'On error, retry with https
On Error GoTo HTTPS_Handler
HTTPS_Handler:
'New String URL, replacing http with https
Dim HTTPS_Input As String = Replace(Input, "http", "https")
'All we did last time, again...
Dim NewUrl As Uri = New Uri(HTTPS_Input)
WebBrowser1.Url = NewUrl
WebBrowser1.Refresh()
End Sub
End Class
...あなたは、古いVB6のスタイルを使用しようとして
動作するはず参照、おそらくいくつかのサイトが自動にしてみてくださいという事実を処理していないにチェックすることができ、エラー変数があるが(HTTPSにリダイレクトこれの例)。 Try/Catchを使用して適切なエラー処理を読み、エラーの原因を教えてください。 http://stackoverflow.com/documentation/vb.net/4232/error-handling/14828/try-catch-finally-statement#t=201608011838059034895 – TyCobb
try/catchを実行しないでこれを行う方法はありますか?ウェブサイトが私をリダイレクトしようとしているのか何とかテストできますか? – UltraLuminous
それは私が言っていることではありません。 try/catchを使用すると、実際に何のエラーが発生しているのかを把握できるので、検索して問題を解決することができます。今、それは爆発していて、あなたは例外を投げ捨てていますが、例外が何だったのか分かりません。 – TyCobb