I am working on a asp.net MVC project. We want to log all our action method calls in this style:
namespace.controller.method(parameter1name: parameter1value, ... parameternname: parameternvalue)
Is this possible in C# or asp.net MVC with an attribute? My idea would be an ActionFilterAttribute
but as I understand them, they are called before the actual method is called.
A few more details, why an ActionFilterAttribute
doesn't work in this case. We want to log the method call with the full .net namespace, the classname, the original method name and all parameters.
Here is an example
namespace MyTestNamespace {
public class HomeController {
[ActionName("Index")]
[HttpGet]
public ActionResult MyCall(string username) {
ViewBag.Great = "Hello " + username;
return View();
}
}
}
The logging output should look like this:
MyTestNamespace.HomeController.MyCall(username: Knerd)
But the logging output I can get with an ActionFilterAttribute
would like this:
MyTestNamespace.HomeController.Index(username: Knerd)