Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Action and Action Parameters in Controller.OnException

We're using the OnException virtual method in BaseController to log our exception.

But how can we get the controller action and parameters that the exception originated from?

like image 527
sternr Avatar asked Sep 22 '11 11:09

sternr


1 Answers

You can get all these data from ExceptionContext object.

For example using this code you can get controller, action and all other routing parameters:

context.RouteData.Values

Using this code you can get query string parameters:

context.HttpContext.Request.QueryString

And finnaly form parameters:

context.HttpContext.Request.Form
like image 60
Egor4eg Avatar answered Sep 21 '22 22:09

Egor4eg