2010-08-06 68 views
0

WCF等效於ActionFilterAttribute是什麼?在REST WCF .net 4.0中相當於ActionFilterAttribute

我有一個REST服務,它看起來像下面

[WebInvoke(Method = "POST", UriTemplate = "/")] 
public User CreateBookMark(BookMark bm) 
{ 
    User authenticateUser = GetUserSomeHow(); 

    //do stuff 

} 

我想改變這下面

[WebInvoke(Method = "POST", UriTemplate = "/")] 
public User CreateBookMark(BookMark bm, User authenticateUser) 
{ 

    //do stuff 

} 

回答

1

創建自定義服務行爲(IServiceBehavior接口) - 掛接一個自定義操作行爲(IOperationBehavior),它將注入額外的參數。它可能是你也想實現你自己的AuthorizationManager - 但它很可能是你可以做的功能(OperationContext.Current.SecurityContext和System.Threading.Thread.CurrentPrincipal)。

+0

你有一個你將如何做的例子嗎? – 2010-08-11 17:33:37