4

I am having issues about redirection to a page after using the Custom Login/Logout.

The scenario is, I need to redirect the user to the Custom Login page, if accessing the Restricted Page (Test Restrict). I can now redirect him to Login Page and can even log in using his Sitecore credentials. After successful login, user is being redirected to the Test Restrict and also seeing the Logout Button.

I have configured the Logout Button that should redirect user to the /sitecore/content/Site/Home when clicked. However, if the Home Page is also restricted to anonymous users, I keep getting a message

Layout request not found

Below is a snippet of my code.

    [HttpPost]
    [ValidRenderingToken]
    public ActionResult Logout(Login loginModel)
    {
        var model = GetDataSourceItem<Login>();


        AuthenticationManager.Logout();
        Session.Abandon();
        FormsAuthentication.SignOut();

        model.LoginUsername = "";
        model.LoginPassword = "";

        var linkUrl = model.TargetPageUrl;

        if (string.IsNullOrEmpty(linkUrl))
        {
            SetReturnUrl();
        }
        else
        {
            ReturnUrl = linkUrl;
        }

        return Redirect(string.IsNullOrEmpty(ReturnUrl) ? "/" : ReturnUrl);
    }

    private void SetReturnUrl()
    {
            if (!string.IsNullOrEmpty(Request.QueryString["returnUrl"]))
                ReturnUrl = Request.QueryString["returnUrl"];    
    }

I am new to this and would like to ask for advice/help. Thanks

3

I have an old support ticket with a confirmed bug by Sitecore Support (on Sitecore 6.5 and 8.0) that a homepage with broken inheritance can lead to a no-layout error. We did get a patch for it (number 325160). If applicable, you should be able to get it from Sitecore Support as well.

I did find the issue as fixed in the release notes of Sitecore Experience Platform 8.2 Update-1 (rev. 161115):

A nolayout page is returned instead of the noaccess page. 90940, 325160

Not sure what you're version is...

  • Too bad im using Sitecore Experience Platform 8.1 Update-3. But i will log a ticket to Sitecore Support. Thanks for this :) – ZQuiray Oct 2 '17 at 6:14
  • No problem - support should be able to give you the patch quickly if you refer to the number. – Gatogordo Oct 2 '17 at 7:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.