public void OnAuthorization(AuthorizationContext filterContext)
 {
     if (_verbs.IsValidForRequest(filterContext, null))
     {
         AntiForgery.Validate();
     }
 }
        public void IsValidForRequestThrowsIfControllerContextIsNull()
        {
            // Arrange
            AcceptVerbsAttribute attr = new AcceptVerbsAttribute("get", "post");

            // Act & Assert
            Assert.ThrowsArgumentNull(
                delegate { attr.IsValidForRequest(null, null); }, "controllerContext");
        }
        public void IsValidForRequestThrowsIfControllerContextIsNull()
        {
            // Arrange
            AcceptVerbsAttribute attr = new AcceptVerbsAttribute("get", "post");

            // Act & Assert
            Assert.ThrowsArgumentNull(
                delegate { attr.IsValidForRequest(null, null); }, "controllerContext");
        }
Example #4
0
        // Methods
        public override bool IsValidForRequest(ControllerContext controllerContext, MethodInfo methodInfo)
        {
            var hccRequestType = (string)controllerContext.RequestContext.RouteData.Values["hccrequesttype"];

            if (Factory.CreateHccFormRenderer().VirtualFormUsed&& !string.IsNullOrEmpty(hccRequestType))
            {
                return(hccRequestType == "hccpost");
            }
            return(_innerAttribute.IsValidForRequest(controllerContext, methodInfo));
        }
        public override bool IsValidForRequest(ControllerContext controllerContext, MethodInfo methodInfo)
        {
            if (!innerAttribute.IsValidForRequest(controllerContext, methodInfo))
            {
                return(false);
            }

            var submitted = controllerContext.RequestContext.HttpContext.Request.Form[submitName];

            return(string.IsNullOrEmpty(submitValue) ? !string.IsNullOrEmpty(submitted) : string.Equals(submitted, submitValue, StringComparison.InvariantCultureIgnoreCase));
        }
        public void IsValidForRequestReturnsTrueIfHttpVerbIsInVerbsCollection()
        {
            // Arrange
            AcceptVerbsAttribute attr    = new AcceptVerbsAttribute("get", "post");
            ControllerContext    context = GetControllerContextWithHttpVerb("POST");

            // Act
            bool result = attr.IsValidForRequest(context, null);

            // Assert
            Assert.IsTrue(result);
        }
        public void IsValidForRequestReturnsTrueIfHttpVerbIsOverridden()
        {
            // Arrange
            AcceptVerbsAttribute attr    = new AcceptVerbsAttribute("put");
            ControllerContext    context = GetControllerContextWithHttpVerb("POST", "PUT", null, null);

            // Act
            bool result = attr.IsValidForRequest(context, null);

            // Assert
            Assert.IsTrue(result);
        }
        public void IsValidForRequestReturnsTrueIfHttpVerbIsOverridden()
        {
            // Arrange
            AcceptVerbsAttribute attr = new AcceptVerbsAttribute("put");
            ControllerContext context = GetControllerContextWithHttpVerb("POST", "PUT", null, null);

            // Act
            bool result = attr.IsValidForRequest(context, null);

            // Assert
            Assert.True(result);
        }
        public void IsValidForRequestReturnsTrueIfHttpVerbIsInVerbsCollection()
        {
            // Arrange
            AcceptVerbsAttribute attr = new AcceptVerbsAttribute("get", "post");
            ControllerContext context = GetControllerContextWithHttpVerb("POST");

            // Act
            bool result = attr.IsValidForRequest(context, null);

            // Assert
            Assert.True(result);
        }
Example #10
0
 // Methods
 public override bool IsValidForRequest(ControllerContext controllerContext, MethodInfo methodInfo)
 {
     return(_innerAttribute.IsValidForRequest(controllerContext, methodInfo));
 }
Example #11
0
 public override bool IsValidForRequest(ControllerContext controllerContext, MethodInfo methodInfo)
 {
     return(_Verbs.IsValidForRequest(controllerContext, methodInfo));
 }
Example #12
0
 public override bool IsValidForRequest(ControllerContext controllerContext, System.Reflection.MethodInfo methodInfo)
 {
     return(_innerDeleteAttribute.IsValidForRequest(controllerContext, methodInfo) ||
            _innerPostAttribute.IsValidForRequest(controllerContext, methodInfo));
 }