Zehan Jurangpathy
Zehan Jurangpathy

Reputation: 55

Stop WCF request from reaching a method

I have a requirement where i need to stop the WCF request from reaching a service method in certain conditions. I read many articles where it says to implement a Message Inspector and write the condition in the AfterReceiveRequest method.

My Question is, is it the best place to do this, or is there a better place in the pipeline where i can implement this?

Any samples would be highly appreciated.

Upvotes: 1

Views: 738

Answers (2)

Rahul
Rahul

Reputation: 77876

i need to stop the WCF request from reaching a service method in certain conditions.

Apparently, to me it looks like on certain condition you don't want to invoke the service method at all; if that's the case then you can probably check for that condition and skip the service call in your consuming client itself. (OR) am I missing something here?

Upvotes: 1

Maximus
Maximus

Reputation: 3448

You can halt request either in custom class deriving IDispatchMessageInspector or in custom class deriving IOperationInvoker. First one is invoked when message/request is received, latter right before operation is invoked so you can suppress its kick-off.

Upvotes: 1

Related Questions