I have an ASP.NET MVC application for which I want to log events. I already have a log class with all the necessary tools, but I need to create an instance and close it explicitly (because it opens files, so I cannot depend on GC). My actions will look like this:
public ActionResult MainMenu() { CreateLog();
Or I could use the using block, but it would be a little less intrusive, and that would create problems with exception handling. I read about ActionFilters , which I could use to create and close my log, but then I would not have access to the log object inside the method.
Do you have any suggestions? How could I avoid repeating the code?
source share