Click here to Skip to main content
15,891,850 members
Articles / Programming Languages / Visual Basic

Configuring Exceptions Using Web.config

Rate me:
Please Sign up or sign in to vote.
3.50/5 (4 votes)
22 Apr 20043 min read 59.3K   16  
An article on handling exceptions using custom handlers, by a custom configuration section, making it independent from using the application.
Imports System
Imports System.Data.SqlClient
Imports System.Configuration
Imports ExceptionManagers

Public Class WebForm1
    Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here

        Dim conn As New SqlConnection()
        conn.ConnectionString = ""
        Try
            conn.Open()
        Catch sqle As SqlException
            Dim url As String = ExceptionManagersHandler.PublishException("AccountsCentre", sqle)
            Response.Redirect(url)
        Catch exp As Exception
            Dim url As String = ExceptionManagersHandler.PublishException("AccountsCentre", exp)
            Response.Redirect(url)
        End Try

    End Sub

End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Pakistan Pakistan
I am an IT graduate , and have secured SCPJ 2 and IBM XML developer cerifications.Started my career as J2EE developer, but now focused on .Net technologies.Currently working as a web developer ,in infinilogic (www.infinilogic.com),a UK based organization , providing business solutions.

Comments and Discussions