Your comment says you are trying to achieve what is in this post, and yet you copied code not from that post at all, but from a previous SO post: Using custom authorization in MVC 4 that was referring to Web API. And in reading that post you see the difference is in what AuthorizeAttribute you use. You are using System.Web.Http
instead of System.Web.Mvc
.
If you used the code that you referred to in your comment, then you'd find it would work:
using System.Web;
using System.Web.Mvc;
namespace MvcApplicationTestProject1
{
public class AuthAttribute : AuthorizeAttribute
{
protected override bool AuthorizeCore(HttpContextBase httpContext)
{
return false;
}
}
}