1
在我的应用程序中,我使用“HandleError”,如果发生错误,我的“Error.vbhtml”视图呈现。这很好,除了现在我还想记录错误。我已经构建了一个自定义的HandleError类,继承了HandleErrorAttribute,并重写了OnException方法。ASP.NET MVC覆盖HandleError导致查看不呈现
现在我的错误得到记录,但Error.vbhtml视图不会得到呈现......我在搞什么祈祷?
Imports System.Web.Mvc
Namespace Mvc.Attributes
Public Class HandleError : Inherits System.Web.Mvc.HandleErrorAttribute
Private ExceptionService As Domain.IExceptionService
Public Sub New()
ExceptionService = New Domain.ExceptionService(New Domain.ExceptionRepository)
End Sub
Public Overrides Sub OnException(ByVal exceptionContext As ExceptionContext)
''# Log the exception if it has not been handled elsewhere
If Not exceptionContext.ExceptionHandled Then
ExceptionService.AddException(exceptionContext.Exception)
ExceptionService.SubmitChanges()
''# Signal to the system that we've handled the exception
exceptionContext.ExceptionHandled = True
End If
End Sub
End Class
End Namespace
尝试调用'base.OnException()'你完成之后登录? [黑暗中射击],另外'HandleError'不是有史以来最好的选择。属性应该始终以名称“Attribute”结尾,并且可能不会与它们继承的类共享名称(即使它们位于不同的名称空间中)。 – 2010-11-16 22:05:47