defaultRedirect = "Error.aspx"
はあなたが未処理の例外を持っている場合、ASP.NETは、(標準の代わりにあなたのError.aspxページを呼び出すことを意味します「死の黄色いスクリーン」と呼ばれる)。私の場合は
私はこのように振る舞う:(あなたの場合、Error.aspxに)処理ページに続いて
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when an unhandled error occurs
Try
Application("errore") = Server.GetLastError
Catch ex As Exception
end try
End Sub
私は取扱いを行います:最初のGlobal.asax
に私は、アプリケーションで未処理の例外を保存
Partial Class Error
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
If Session("userid") <> "" Then
'Ho avuto una eccezione vera !
Dim ex As Exception = Application("errore")
Application("errore") = Nothing
If IsNothing(ex) Then
ex = Server.GetLastError()
End If
If Not IsNothing(ex) Then
Dim bex As Exception = ex.GetBaseException
If IsNothing(bex) Then
bex = ex
End If
'Show details of exception bex on page or store in DB
Catch exall As Exception
End Try
End If
End If
End If
End If
End Sub
End Class
catchの「error.aspx」にリダイレクトしたいと思っていますか?もしそうなら、あなたは単にResponse.Redirect( "Error.aspx")を実行できませんでしたか?あなたの質問はちょっと不明かもしれませんが、あなたがキャッチで何をしようとしているのか正確に説明できますか? – JKerny
catch {}でエラーをキャッチして、のエラーコードに基づいてエラーページを自動的に表示します。 –
Syy
いくつかのコードを記述する必要があります。これはあなたのロジックを試してラップしたり、数行の設定を追加したりすることで自動的に起こるものではありません。ここでは、Web設定404について説明します。https://stackoverflow.com/questions/4483849/default-redirect-for-error-404 – JKerny