I'm currently trying to integrate postsharp with my asmx web service for the purpose of logging exceptions.
Here's my code for the Aspect perspective:
[Serializable]
public class LogPerformance : OnMethodBoundaryAspect
{
public override void OnEntry(MethodExecutionArgs args)
{
string test = "test";
base.OnEntry(args);
}
public override void OnExit(MethodExecutionArgs args)
{
string test = "test";
base.OnExit(args);
}
public override void OnException(MethodExecutionArgs args)
{
string test = "test";
base.OnException(args);
}
}
while in my Service.cs class, i've the following web method:
[WebMethod(EnableSession = true)]
[SoapHeader("authentication")]
[LogPerformance]
public DataTable loginUser(string userName, string password)
{
doStuff();
}
Coming straight to the point:
- Does postsharp support implementation with web methods? As in my case, postSharp methods does not get called whenever the web method receives a hit. (Yes i've added postsharp reference using Nuget and/or/plus manually added its dll as well) This does suggest a step towards the mentioned subject but i could not make anything out of it.
It is important to note that the same LogPerformance Class runs smoothly when integrated with:
- Web API
- ASP.Net Web Application (MVC)
- Console Application
The problem is when i use it with .asmx web service. A little nudge towards the right direction would be appreciated.