Network Analyst routing
ArcGIS_Routing_VBNet\ErrorPage.aspx.vb
' Copyright 2010 ESRI
' 
' All rights reserved under the copyright laws of the United States
' and applicable international laws, treaties, and conventions.
' 
' You may freely redistribute and use this sample code, with or
' without modification, provided you include the original copyright
' notice and use restrictions.
' 
' See the use restrictions.
' 




Imports Microsoft.VisualBasic
Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Data
Imports System.Web
Imports System.Web.SessionState
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls

Namespace RouteFinder
  Partial Public Class ErrorPage
    Inherits System.Web.UI.Page
    ' Before deploying application, set showTrace to false
    ' to prevent web application users from seeing error details
    Private showTrace As Boolean = True

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
      'get error message stored in session
      Dim message As String = CStr(Session("ErrorMessage"))

      'get details of error from exception stored in session
      Dim errorDetail As String = String.Empty
      Dim exception As Exception = TryCast(Session("Error"), Exception)
      If Not exception Is Nothing Then
        Select Case exception.GetType().ToString()
          Case "System.UnauthorizedAccessException"
            Dim errorAccess As UnauthorizedAccessException = TryCast(exception, UnauthorizedAccessException)
            If errorAccess.StackTrace.ToUpper().IndexOf("SERVERCONNECTION.CONNECT") > 0 Then
              errorDetail = "Unable to connect to server. <br>"
            End If
        End Select
        errorDetail &= exception.Message
      End If

      'create response and display it
      Dim response As String
      If Not message Is Nothing AndAlso message <> String.Empty Then
        response = String.Format("{0}<br>{1}", message, errorDetail)
      Else
        response = errorDetail
      End If
      lblError.Text = response
      If (showTrace) AndAlso (Not exception Is Nothing) Then
        lblExtendedMessage.Text = exception.StackTrace
      End If
    End Sub

#Region "Web Form Designer generated code"
    Protected Overrides Sub OnInit(ByVal e As EventArgs)
      '
      ' CODEGEN: This call is required by the ASP.NET Web Form Designer.
      '
      InitializeComponent()
      MyBase.OnInit(e)
    End Sub

    ''' <summary>
    ''' Required method for Designer support - do not modify
    ''' the contents of this method with the code editor.
    ''' </summary>
    Private Sub InitializeComponent()

    End Sub
#End Region
  End Class
End Namespace