Example #1
0
        public ActionResult Index()
        {
            var connectionInfo = this.Session.GetConnectionInfo();
            if (connectionInfo == null || !ActiveConnections.ContainsKey(connectionInfo.ConnectionId))
            {
                return this.View("Login");
            }

            var clientDeviceInfo = this.Session.GetClientDeviceInfo();
            if (clientDeviceInfo == null)
            {
                var clientDeviceInfoHeightCookie = this.Request.Cookies["client-device-height"];
                var clientDeviceInfoWidthCookie = this.Request.Cookies["client-device-width"];
                
                int clientDeviceInfoHeight, clientDeviceInfoWidth;
                if (clientDeviceInfoHeightCookie != null && int.TryParse(clientDeviceInfoHeightCookie.Value, out clientDeviceInfoHeight) &&
                    clientDeviceInfoWidthCookie != null && int.TryParse(clientDeviceInfoWidthCookie.Value, out clientDeviceInfoWidth))
                {
                    clientDeviceInfo = new ClientDeviceInfo
                    {
                        ScreenResolution = new System.Drawing.Size(clientDeviceInfoWidth, clientDeviceInfoHeight)
                    };

                    this.Session.SetClientDeviceInfo(clientDeviceInfo);
                }
                else
                {
                    return View("NewSession");
                }
            }

            return View();
        }
Example #2
0
 public static void SetClientDeviceInfo(this HttpSessionStateBase session, ClientDeviceInfo clientDeviceInfo)
 {
     session[ClientDeviceInfoSessionId] = clientDeviceInfo;
 }