Blog.Common.Web.Attributes.BlogAuthorizationAttribute.OnAuthentication C# (CSharp) Method

OnAuthentication() public method

public OnAuthentication ( System.Web.Mvc.Filters.AuthenticationContext filterContext ) : void
filterContext System.Web.Mvc.Filters.AuthenticationContext
return void
        public void OnAuthentication(AuthenticationContext filterContext)
        {
            try
            {
                filterContext.Result = GetCodeResult(filterContext);
            }
            catch (Exception ex)
            {
                ErrorSignaler.SignalFromCurrentContext(ex);
                throw new BlogException(ex.Message, ex.InnerException);
            }
        }

Usage Example

        public void ShouldReturnUnauthorizedWhenNotAuthenticated()
        {
            _requestBase.SetupGet(r => r.IsAuthenticated).Returns(false);

            var attribute = new BlogAuthorizationAttribute();
            attribute.OnAuthentication(_authenticationContext.Object);

            Assert.IsInstanceOf(typeof(HttpUnauthorizedResult), _authenticationContext.Object.Result);
        }
All Usage Examples Of Blog.Common.Web.Attributes.BlogAuthorizationAttribute::OnAuthentication