I'm creating an ASP.NET MVC application. I need to handle exceptions in two places.
Global.asax.vb file:
Public Class MvcApplication
Inherits System.Web.HttpApplication
...
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
LogException(HttpContext.Current.Server.GetLastError(), Request)
End Sub
Shared Sub LogException(ByVal ex As Exception, ByRef r As System.Web.HttpRequest)
...
End Sub
End Class
Views\Shared\Error.aspx file:
<%@ Page Language="VB" Inherits="System.Web.Mvc.ViewPage(Of System.Web.Mvc.HandleErrorInfo)" %>
<script runat="server">
Sub Page_Load(ByVal Sender As System.Object, ByVal e As System.EventArgs)
MvcApplication.LogException(Model.Exception, Request)
End Sub
</script>
...
But I get this error:
C:\inetpub\example.com\Views\Shared\Error.aspx(5): error BC30451: Name 'MvcApplication' is not declared.
Where should I define my LogException() function so that it is accessible from both the Global.asax.vb file and the Error.aspx file? Where is the most MVC-ish?