public static void LogViewState(HttpContext context, Page page, bool before)
        {
            var logType = before ? LogType.OnPageViewStateBefore : LogType.OnPageViewStateAfter;
            NameValueCollection viewStateValues = LoggingHelper.GetViewStateValues(page);

            var postBackControlClientId = GetPostBackControlClientId(context, page, requestForm: null);

            var newLogElement = new LogElementDTO(
                guid: Guid.NewGuid(),
                sessionGUID: LoggingHelper.GetSessionGUID(context, page, () => new Guid()).Value,
                pageGUID: LoggingHelper.GetPageGUID(context, page, () => new Guid()).Value,
                bundleGUID: null,
                progressGUID: null,
                unixTimestamp: TimeHelper.UnixTimestamp(),
                logType: logType,
                element: LoggingHelper.StripUrlForLRAP(context.Request.RawUrl),
                element2: postBackControlClientId,
                value: viewStateValues != null ? SerializationHelper.SerializeNameValueCollection(viewStateValues, SerializationType.Json) : null,
                times: 1,
                unixTimestampEnd: null,
                instanceTime: DateTime.Now,
                stackTrace: null
                );

            if (LoggingHelper.IsPlaying(context, requestForm: null))
            {
                var serverGUID  = LoggingHelper.GetServerGUID(context, () => { throw new Exception(); }).Value;
                var sessionGUID = LoggingHelper.GetSessionGUID(context, page, null);
                var pageGUID    = LoggingHelper.GetPageGUID(context, page, null);

                if (LoggingHelper.FetchAndExecuteLogElement(serverGUID, sessionGUID, pageGUID, logType, (logElement) =>
                {
                    TimeHelper.SetNow(context, logElement.InstanceTime);

                    if (logElement.Value != null)
                    {
                        NameValueCollection loggedViewStateValues = SerializationHelper.DeserializeNameValueCollection(logElement.Value, SerializationType.Json);
                        LoggingHelper.SetViewStateValues(page, loggedViewStateValues);
                    }
                    else if (viewStateValues != null)
                    {
                        throw new Exception("ViewState difference");
                    }

                    PlayerCommunicationHelper.SetLogElementAsDone(serverGUID, sessionGUID, pageGUID, logElement.GUID, jobStatus: new JobStatus()
                    {
                        Success = true
                    });                                                                                                                                               //, async: false); //Non deadlock, because we would never call the webserver via namedpipe back again
                }))
                {
                    return;
                }
            }

            LoggingHelper.LogElement(newLogElement);
        }