For my site I need to have:
- logging of the action & render time
- log the visit of a certain product
- from time to time agregate votes
- from time to time send newsletter
- from time to time post on social networks
My approach to this was to create a global filter and OnResultExecuted I do the check and the action that are needed.
I have some questions:
- when OnResultExecuted is running did the user received the rendered page and basically is not waiting for anything else? Am I blocking it?
- it is a good idea in OnResultExecuted to start a new thread for this
jobs? - is this approach ok in ASP MVC 4
According to MSDN this method is called after the response is written (http://msdn.microsoft.com/en-us/library/system.web.mvc.controller.onresultexecuted(v=vs.108).aspx) so you will not be blocking the response.
Apart from the first two points (logging of actions and logging of visits), the others may take considerable resources based on the size of the task.
My advice is to override OnResultExecuted for the first two tasks and use a windows service (can easily be written in C#) to do the others in the background. This way you can use less costly clr threads instead of iis worker threads.
Running the time/resource consuming tasks in the background will add scalability to your web application
Hope this helps