Creating a custom Authorize attribute with specific rules
<p>I'm trying to create a custom Authorize attribute to do the following:</p>

<ol>
<li>If the user has a role of "Regular user" - he is redirected to /index/subscribe</li>
<li>All other users(Administrator,Subscriber) gets access to /Search/Index</li>
</ol>

<p>This is when the user tries to open up the Search controller. I made the custom Authorize attribute like this:</p>

<pre><code>public class DenyRegularUser : System.Web.Mvc.AuthorizeAttribute
    {
        public override void OnAuthorization(AuthorizationContext filterContext)
        {
            base.OnAuthorization(filterContext);
            if (!filterContext.HttpContext.User.Identity.IsAuthenticated)
            {
                filterContext.Result = new RedirectResult("~/User/Logon");
                return;
            }

            if (filterContext.HttpContext.User.IsInRole("Regular user"))
            {
                filterContext.Result = new RedirectResult("~/Index/Subscribe");
            }
        }
    }
</code></pre>

<p>And this is my Search controller:</p>

<pre><code>namespace WebApplication2.Controllers
{
    [DenyRegularUser(Roles ="Regular user")]
    public class SearchController : Controller
    {
        // GET: Search
        public ActionResult Index()
        {
            return View();
        }
    }
}
</code></pre>

<p>But for some reason, even when I update the user's role from Regular user to Administrator or Subscriber, I get redirected to login page: /user/login...</p>

<p>This shouldn't happen as the login functionality works perfectly and I get the role of the user...</p>

<p>What am I missing out here??</p>