<% Class ErrorController_Class Private m_useLayout Private Sub Class_Initialize() m_useLayout = True End Sub ' JSON API requests (/api/...) get JSON errors without the HTML layout Public Property Get useLayout If IsApiRequest() Then useLayout = False Else useLayout = m_useLayout End If End Property Private Function IsApiRequest() IsApiRequest = (LCase(Left(GetRequestPath(), 5)) = "/api/") End Function Public Property Let useLayout(v) m_useLayout = v End Property Public Sub Index() Response.Write "Index called" End Sub Public Sub NotFound() If IsApiRequest() Then Api_Error 404, "not_found", "No such endpoint." Exit Sub End If Response.Status = "404 Not Found" %> <% End Sub ' The path exists, but not for this HTTP method (resolved by Router_Class.AllowedMethods) Public Sub MethodNotAllowed(allow) If IsApiRequest() Then Api_Error 405, "method_not_allowed", "Use one of: " & allow & "." Else Response.Status = "405 Method Not Allowed" Response.Write "

Method not allowed. Use one of: " & Server.HTMLEncode(allow) & ".

" End If Response.AddHeader "Allow", allow End Sub ' Static action dispatch (AxonASP mishandles runtime-built Eval/Execute calls), ' called through Controller_Invoke at the bottom of this file. Public Sub Invoke(actionName, args) Select Case LCase(actionName) Case "index" : Index Case "notfound" : NotFound Case "methodnotallowed" : MethodNotAllowed args(0) Case Else Err.Raise 438, "ErrorController_Class", "Action '" & actionName & "' not found" End Select End Sub End Class Dim ErrorController_Class__Singleton Function ErrorController() If IsEmpty(ErrorController_Class__Singleton) Then Set ErrorController_Class__Singleton = New ErrorController_Class End If Set ErrorController = ErrorController_Class__Singleton End Function ' Global entry point used by MVC_InvokeAction via GetRef. A separate call site per controller ' avoids AxonASP binding a shared call site to the first controller's Invoke. Sub ErrorController_Invoke(actionName, args) ErrorController().Invoke actionName, args End Sub %>