代码之家  ›  专栏  ›  技术社区  ›  ps.

REST WCF.net 4.0中的ActionFilterAttribute等效项

  •  0
  • ps.  · 技术社区  · 15 年前

    什么是 ActionFilterAttribute 相当于 WCF ?

    我有一个休息服务,如下所示

    [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 回复  |  直到 13 年前
        1
  •  1
  •   larsw    15 年前

    创建一个自定义服务行为(IServiceBehavior)-它连接一个自定义操作行为(IOperationBehavior),该行为将注入额外的参数。您可能还想实现自己的AuthorizationManager,但很可能您可以使用这些功能(OperationContext.Current.SecurityContext和System.Threading.Thread.CurrentPrincipal)。

    推荐文章