Redirect to original preview URL after login through sitecore

I saw a question recently on Stackoverflow asking about when you send a preview link to the next person in workflow for approval, assuming that person is not logged in into sitecore yet, the preview link will redirect to sitecore login page, and after logining in, sitecore will forget about the orginal preview URL and go directly into sitecore desktop/Content editor.

So, after looking into how sitecore login pipeline works, i found this solution:

  1. In your web.config, set Authentication.SaveRawUrl to true, this will make the original requested URL passed to login page in a query string 'url'
  2.  Create class called "LoginRedirect": 
    using System.Web;
    using Sitecore.Pipelines.LoggedIn;
    using Sitecore.Web;
    
    namespace Sitecore.SharedResources.Pipelines.Login {
    
     public class LoginRedirect : LoggedInProcessor {
    
    
        public override void Process(LoggedInArgs args) {
    
          if (Sitecore.Context.GetSiteName() != "login") { return; }
    
          string url = HttpUtility.UrlDecode(
              WebUtil.GetQueryString("url", "")
          );
          if (!string.IsNullOrWhiteSpace(url)) {
            WebUtil.Redirect(url);
          }
        }
    
      }
    }
  3. Create a config file inside your include folder with the following:
    
      
        
          
            
           
      
    

Leave your thoughts in comments!

Comments

  1. Select the material with the bottom value that has properties that fulfill your high precision machining design necessities. Design elements that may be} machined in one or two setups in a 3-axis CNC mill. [newline]Silk screening is an inexpensive approach to print text or logos on the floor of CNC machined elements for aesthetic purposes. Tool metal Exceptionally high hardness, stiffness, abrasion and thermal resistance.

    ReplyDelete
  2. If your phone/tablet blocks the download, enable “Downloads from Unknown Sources” in your safety settings. This is a 3-reel pokies recreation that has a 96.8% RTP and multiple of} possibilities of successful. The greatest fee technique is the method that's the most accessible to you, nicely as|in addition to} the one you feel essentially the most comfy utilizing. Some of the providers referred to on our web site may be be} considered to be prohibited interactive gambling providers beneath the interactive Gambling Act 2001 . I am over 18 and have read and accepted the terms of use and privateness coverage. By ticking this box I affirm I am happy to obtain newsletters and 사설토토 advertising from PokerNews.

    ReplyDelete

Post a Comment

Popular posts from this blog

Building Sitecore Content Search Queryable using Rules engine

Attaching a file on WFFM Send email action

Caching Rendering HTML when conditional rules are applied