what is the ActionFilterAttribute
equivalent in WCF
?
I have a REST service which looks like below
[WebInvoke(Method = "POST", UriTemplate = "/")]
p开发者_C百科ublic User CreateBookMark(BookMark bm)
{
User authenticateUser = GetUserSomeHow();
//do stuff
}
I want to change this to following
[WebInvoke(Method = "POST", UriTemplate = "/")]
public User CreateBookMark(BookMark bm, User authenticateUser)
{
//do stuff
}
Create a custom service behavior (IServiceBehavior) - that hooks up a custom operation behavior (IOperationBehavior) that will inject the the extra parameter. It may be you also want to implement your own AuthorizationManager - but it's most likely that you can do with the features (OperationContext.Current.SecurityContext and System.Threading.Thread.CurrentPrincipal).
精彩评论