。NET MVC [AllowAnonymous] 跳过授权过滤器

[AllowAnonymous]
        public JsonResult LoaderColumns(JObject data)
        {
            DataTable dt = RunProcedureDataTable(data, "sed_s_smp_man_list");
            if (data["loader"].ToString()== "pinZhong" && data["value"].ToString()!="" && dt.Rows.Count==0)
            {
                ProcInfo pi = new ProcInfo();
                string sql = @"(SELECT VarietyName AS pinZhong,
                                        VarietySource AS zuHe,
                                        JudgementNo AS shenDingBH,
                                        {0} AS cloader
                                 FROM dbo.VarietyApproval
                                 WHERE VarietyName = '{1}')
                                UNION
                                (SELECT VarietyName AS pinZhong,
                                        VarietySource AS zuHe,
                                        NULL AS shenDingBH,
                                        {0} AS cloader
                                 FROM dbo.VarietyRegistration
                                 WHERE VarietyName = '{1}')";

                pi.SQL = String.Format(sql, data["loader"].ToString(), data["value"].ToString());
                pi.Type = "sql";
                pi.ConnStr = "bigData";
                DataSet ds= RunProcedureDataSet(data, pi);
                if (ds.Tables[0].Rows.Count != 0)
                {
                    dt = ds.Tables[0];
                }
            }
            //return JsonConvert.SerializeObject(dt);


            return JsonNet(dt);
        }

/// <summary>
    /// 自定义Action过滤器:垃圾回收
    /// </summary>
    [AttributeUsage(AttributeTargets.All, AllowMultiple = true)]//多次调用
    public class CustomDisposeFilter : ActionFilterAttribute
    {
        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            //判断是否跳过授权过滤器
            if (filterContext.ActionDescriptor.IsDefined(typeof(AllowAnonymousAttribute), true)
                || filterContext.ActionDescriptor.ControllerDescriptor.IsDefined(typeof(AllowAnonymousAttribute), true))
            {
                return;
            }
            base.OnActionExecuted(filterContext);
            GC.Collect();
        }
    }
posted @ 2020-06-02 14:49  唯爱金生  阅读(547)  评论(0编辑  收藏  举报