PreRequestHandlerExecute event not fired for REST calls
c#, global-asax, wcf
Solution
I got it!
I found the answer in this article:
http://blogs.msdn.com/wenlong/archive/2006/01/23/516041.aspx
When using WCF in the mixed mode, the module intercepts the request in the early stage of the pipeline: BeginRequest. That means the other events are never called.
To fix that, I changed my web.config to make WCF work in the Asp.Net compatibility mode:
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
</system.serviceModel>
And then explicitely tell my service to be compatible too:
[AspNetCompatibilityRequirements(RequirementsMode =
AspNetCompatibilityRequirementsMode.Allowed)]
public class MyService : IMyService { ...
And done! Now I have all events and also the HttpContext.Current instead of OperationContext.Current
I hope this helps someone with the same problem.
Cheers,
André Carlucci
Problem
I'm creating my nhibernate session in the PreRequestHandlerExecute event handler of the HttpApplication class. It works fine for MVC, however, when in WCF (REST) the event is never fired. Is there a way to make it happen or any other better idea to set the session both in MVC and WCF/Rest? Thanks in advance, André Carlucci