1 Response to Sitecore: Login to website and how to restrict access to content

  1. gorhal says:

    Great post :-)
    There is a third option for “Profile” and it’s item/pages below. In your controller add a custom authentication attribute. Like this:

    public ActionResult ProfileHome()
    return this.View();

    Your custom attribute(from habitat):
    public class RedirectUnauthenticatedAttribute : ActionFilterAttribute, IAuthorizationFilter
    private readonly IGetRedirectUrlService _getRedirectUrlService;

    public RedirectUnauthenticatedAttribute() : this(new GetRedirectUrlService())

    private RedirectUnauthenticatedAttribute(IGetRedirectUrlService getRedirectUrlService)
    this._getRedirectUrlService = getRedirectUrlService;

    public void OnAuthorization(AuthorizationContext context)
    if (Sitecore.Context.User.IsAuthenticated)
    var link = this._getRedirectUrlService.GetRedirectUrl(AuthenticationStatus.Unauthenticated, context.HttpContext.Request.RawUrl);
    context.Result = new RedirectResult(link);


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.