Пример #1
0
 protected BaseDescription(MemberInfo m)
 {
     this.OutputCache = m.GetMyAttribute <OutputCacheAttribute>();
     this.SessionMode = m.GetMyAttribute <SessionModeAttribute>();
     this.Authorize   = m.GetMyAttribute <AuthorizeAttribute>(true /* inherit */);
     this.LogAttr     = m.GetMyAttribute <LogAttribute>(true /* inherit */);
 }
Пример #2
0
        internal static void ExecuteAction(HttpContext context, InvokeInfo vkInfo)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (vkInfo == null)
            {
                throw new ArgumentNullException("vkInfo");
            }

            SetMvcVersionHeader(context);

            LogAttribute logAttr = vkInfo.GetLogAttribute();

            if (logAttr != null)
            {
                logAttr.Log(context);
            }


            // 验证请求是否允许访问(身份验证)
            AuthorizeAttribute authorize = vkInfo.GetAuthorize();

            if (authorize != null)
            {
                if (authorize.AuthenticateRequest(context) == false)
                {
                    throw new PermissionDeniedException();
                }
                //ExceptionHelper.Throw403Exception(context);
            }

            // ASP.NET的安全检查
            if (vkInfo.Action.Attr.NeedValidateRequest())
            {
                context.Request.ValidateInput();
            }


            // 调用方法
            object result = ExecuteActionInternal(context, vkInfo);

            // 设置OutputCache
            OutputCacheAttribute outputCache = vkInfo.GetOutputCacheSetting();

            if (outputCache != null)
            {
                outputCache.SetResponseCache(context);
            }


            // 处理方法的返回结果
            OutputActionResult(context, result);
        }