Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force WCF to call a method on every request before entering actual function

I have a RESTful WCF service with many different functions. For each function I need to call an authentication method that I have written. I can manually call this method on every request but I was looking for a way to force the WCF engine to call this method before these functions are entered. Does anyone know if this is possible?

Cheers

like image 211
brianstewey Avatar asked Nov 25 '09 17:11

brianstewey


2 Answers

You could use the "Custom Behavior" approach.

You would need to write a Class that implements IDispatchMessageInspector. The following MSDN magazine article gives a nice explanation of this: Extending WCF with Custom Behaviors (link points to Wayback Machine cached copy; downloads likely don't work).

like image 52
Subbu Avatar answered Nov 01 '22 20:11

Subbu


To force WCF REST Service to first call a method especially if it's for authorization customize/override CheckAccessCore method of System.ServiceModel.ServiceAuthorizationManager refer: http://msdn.microsoft.com/en-us/library/ms731774(v=vs.110).aspx

like image 2
AbhishekS Avatar answered Nov 01 '22 21:11

AbhishekS