Dưới đây là những gì tôi đang cố gắng để làm trong Global.asax.vb tôi:Làm thế nào để đăng nhập ngoại lệ unhandled trong ASP.NET MVC?
Public Class MvcApplication
Inherits System.Web.HttpApplication
Shared Sub RegisterRoutes(ByVal routes As RouteCollection)
routes.IgnoreRoute("{resource}.axd/{*pathInfo}")
routes.MapRoute(_
"Error", _
"error.html", _
New With {.controller = "Error", _
.action = "FriendlyError"} _
)
...
'other routes go here'
...
End Sub
Sub Application_Start()
RegisterRoutes(RouteTable.Routes)
End Sub
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
...
'code here logs the unhandled exception and sends an email alert'
...
Server.Transfer("http://www.example.com/error.html")
End Sub
End Class
Nhưng đó Server.Transfer thất bại:
Invalid path for child request 'http://www.example.com/error.html'. A virtual path is expected.
Làm thế nào để sửa lỗi này ? Hoặc, cách nào tốt hơn để tôi làm điều này?
Chúng tôi sử dụng một phiên bản sửa đổi của ELMAH ở đây trên Stack Overflow - nó rất tốt. –
@Jarrod - Bạn đã bao gồm những thứ gì trong ngã ba? –
Quy tắc ELMAH - hữu ích hơn log4net của nó. IMHO. – MikeJ