Q:

Asp.Net MVC3 Redirect unauthenticated user to page B only if had browse through page A first

I am new to the ASP.NET MVC programming. 
I have the following code in my site which redirects all the unsigned users to pages located at folder \content\, depending the ending of the page that they are currently. 
How can I modify this code in order to not do the redirect if the user has already been redirected to this page?
using System.Globalization;
using System.Web;
using System.Web.Mvc;

namespace MYSITE.Web.Infrastructure
{
    public class CategoryRedirectAttribute : ActionFilterAttribute
    {
        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            if (!HttpContext.Current.User.Identity.IsAuthenticated)
            {
                if (((ViewResult)filterContext.Result).ViewName.StartsWith("ProductList", true, CultureInfo.InvariantCulture))
                {
                    var categoryProductPath = filterContext.RouteData.Values["categoryProductPath"].ToString().Split('/');
                    if (categoryProductPath.Length > 0)
                    {
                        HttpContext.Current.Response.Redirect("/Content/" + categoryProductPath[categoryProductPath.Length - 1]);
                    }
                }
            }
        }
    }
}

A:

You're making life difficult for yourself. You can use role-based FormsAuthentication to identify users and the [Authorize] attribute on your controllers or action methods to can control who can do what.
Hopefully, you'll find this useful: http://msdn.microsoft.com/en-us/library/ff398049(v=vs.100).aspx

