samy
samy

Reputation: 14962

asp.net mvc: is this request routed or not?

in order to estimate the execution time of the requests sent to my mvc applications, i've been using log4net to log the time elapsed in the EndRequest event of global.asax for my MVC application. However, the EndRequest is called for every request, including the resources (css, images); i'd prefer to be able and distinguish between the two kinds of requests.

Is there a way to separate routed requests from static content requests? Should i abandon this hooking spot and time the execution at another point in the code?

Upvotes: 1

Views: 108

Answers (2)

mookid8000
mookid8000

Reputation: 18628

I usually derive all my controller from a ControllerBase class, into which I insert the necessary logging in the OnActionExecuting and OnActionExecuted method overrides.

This gives me one central place to put the logging for all my controller actions + more stuff that usually would have piled up in all my action methods throughout all my controllers.

Upvotes: 1

Martin
Martin

Reputation: 11041

Check out Phil Haack's Route Debugger.

Upvotes: 1

Related Questions