Workflow Soluiton

 View Only
  • 1.  Redirect back to workflow from the "Session timed out" error page

    Posted Jun 04, 2015 07:17 AM

    When we used Workflow Solution 7.0, we added this script to the end of the workflow projects' ErrorPage.aspx:

    <script language="javascript">
        var s = document.getElementById("lblErrorMessage").innerHTML;
        if(s.indexOf("session has timed out") > 0) {
            window.location.assign("?timedOut=True"); 
            // This redirects to https://our-domain.com/our-workflow/default.aspx?timedOut=True
        }
    </script>    

     

    What this does, is following:

    If user ends up on the ErrorPage.aspx  and it says "Invalid session key or session has timed out", then we redirect the user automatically back to the workflow URL so that they can get a fresh session. We pass a URL parameter timedOut=True to the new session so that it can inform the user, that "Welcome back! Unfortunately you had to start over again, because your previous session timed out".

    In our environment users rarely need to be informed that a session does not exist or timed out. They just want to get back to the workflow.

    BUT

    In Workflow Solution 7.5, the ErrorPage.aspx does not contain the error description label anymore. So we cannot distinct the timeout error from other errors. We don't want to redirect the user back to the workflow if the workflow itself directs to the error page for some reason... for some reason ... for some reason ... for some reason.. right?

    So what would be another way to script the ErrorPage.aspx to redirect back to the workflow URL if the reason of the error was "session has timed out".?

     

    Cheers,

    Mikael



  • 2.  RE: Redirect back to workflow from the "Session timed out" error page
    Best Answer

    Posted Jun 05, 2015 06:35 AM

    Figured out a solution for this.

    To automatically re-direct users from the "session not found" error page to a new session in Workflow Solution 7.5, I add the following to the beginning of the ErrorPage.aspx:

     

    <%@Page Language="C#" AutoEventWireup="true" UICulture="auto" Culture="auto" meta:resourcekey="page"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["LastError"] != null)
        {
            Exception lastException = Session["LastError"] as Exception;
            if (lastException != null)
            {
                Exception actualException = lastException.GetBaseException();
    
                if (actualException != null)
                {
                    if(actualException.Message.IndexOf("was not found") >= 0) {
                        Response.Redirect("https://my-site.com/my-workflow/Default.aspx?timedOut=True");
                    }
                }
            }
        }
    }
    </script>