这是我在Global.asax.vb中尝试做的事情:
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 失败:
无效的子请求路径 'http://www.example.com/error.html'。应使用虚拟路径。
我该如何解决这个问题?或者,有更好的方法吗?