Get ActionName, ControllerName and AreaName and pass it in ActionFilter Attribute

前端 未结 5 491
星月不相逢
星月不相逢 2021-01-31 08:34

I use a custom AuthorizationFilter like the followings:

public class ActionAuthorizeAttribute : AuthorizeAttribute {

protected override bool AuthorizeCore(Syste         


        
5条回答
  •  隐瞒了意图╮
    2021-01-31 08:52

    If getting the area did not work, you can fetch are from the RouteData in this way:

     string currentArea = string.Empty;
     if (rd.DataTokens.TryGetValue("area", out object area))
     {
         currentArea = area.ToString();
     }
    

提交回复
热议问题