public static string InsertLRAPScript(string html, LRAPValues lrapValues)
        {
            var lrapPreScript  = $"<script type=\"text/javascript\" src=\"/logrecorderandplayerjs.lrap?v={AssemblyHelper.RetrieveLinkerTimestamp().Ticks}\"></script><script type=\"text/javascript\">logRecorderAndPlayer.preInit(\"{lrapValues.SessionGUID}\", \"{lrapValues.PageGUID}\", \"{(lrapValues.ServerGUID != null ? lrapValues.ServerGUID.ToString() : "")}\");</script>";
            var newHTML        = html.Insert(LoggingHelper.GetHtmlIndexForInsertingLRAPJS(html), lrapPreScript);
            var lrapPostScript = $"<script type=\"text/javascript\">logRecorderAndPlayer.postInit(\"{lrapValues.SessionGUID}\", \"{lrapValues.PageGUID}\", \"{(lrapValues.ServerGUID != null ? lrapValues.ServerGUID.ToString() : "")}\");</script>";

            newHTML += lrapPostScript;
            return(newHTML);
        }
        private void Context_EndRequest(object sender, EventArgs e)
        {
            if (!Configuration.Enabled || !AllowApplicationObject(sender as HttpApplication))
            {
                return;
            }

            if (responseWatcher == null)
            {
                return; //e.g. Invalid web.config setting
            }
            string response = responseWatcher.ToString();


            HttpApplication application = (HttpApplication)sender;
            HttpContext     context     = application.Context;

            if (IsLRAP(context.Request))
            {
                LRAPHttpManager.ProcessLRAPFile(context);
                return;
            }

            var page    = context?.CurrentHandler as Page;
            var handler = context?.CurrentHandler as IHttpHandler;

            if (page != null || handler != null)
            {
                var sessionGUID = LoggingHelper.GetSessionGUID(context, page, () => new Guid());
                var pageGUID    = LoggingHelper.GetPageGUID(context, page, () => new Guid());
                var serverGUID  = LoggingHelper.GetServerGUID(context, () => null);

                if (page != null)
                {
                    response = LoggingPage.LogResponse(context, page, response);
                }
                else
                {
                    response = LoggingHandler.LogResponse(context, response);
                }

                if (context.Response.ContentType == ContentType.TextHtml)
                {
                    var lrapValues  = new LRAPValues(sessionGUID, pageGUID, serverGUID);
                    var newResponse = LRAPHttpManager.InsertLRAPScript(response, lrapValues);
                    context.Response.Clear();
                    context.Response.Write(newResponse);
                }
            }
        }