开发者

ActionFilterAttribute equivalent in REST WCF .net 4.0

开发者 https://www.devze.com 2023-01-10 18:48 出处:网络
what is the ActionFilterAttribute equivalent in WCF? I have a REST service which looks like below [WebInvoke(Method = \"POST\", UriTemplate = \"/\")]

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).

0

精彩评论

暂无评论...
验证码 换一张
取 消