コード例 #1
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            BasicAuthentication auth;

            switch (type)
            {
            default:
                auth = new DeviceAuthentication();
                break;
            }

            if (!auth.Authenticated(filterContext.HttpContext.Request))
            {
                filterContext.Result = new HttpUnauthorizedResult();
            }

            base.OnActionExecuting(filterContext);
        }
コード例 #2
0
        public override void OnActionExecuting(System.Web.Http.Controllers.HttpActionContext actionContext)
        {
            BasicAuthentication auth;

            switch (type)
            {
            default:
                auth = new DeviceAuthentication();
                break;
            }

            if (!auth.Authenticated(actionContext.Request))
            {
                actionContext.Response = new HttpResponseMessage(HttpStatusCode.Unauthorized);

                var log = LogManager.GetLogger(GetType());
                log.Info("HttpStatusCode.Unauthorized");
            }

            base.OnActionExecuting(actionContext);
        }