這裏就是我想在我Global.asax.vb做:如何在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
但是Server.Transfer的失敗:
Invalid path for child request 'http://www.example.com/error.html'. A virtual path is expected.
我該如何解決這個問題?或者,有什麼更好的方式來做到這一點?
「〜/ error.html」:執行/error.html的子請求時出錯。 – 2009-05-01 16:08:04
「/error.html」:執行/error.html的子請求時出錯。 – 2009-05-01 16:08:08