public CookieContainer Authenticate(string username, string password)
        {
            try
            {
                var requester = new WebPageRequester(_logger);

                _logger.WriteInfoMessage("Authenticate - Getting session cookies");
                var cookies = new CookieContainer();
                requester.Get(_URL_GETSESSIONCOOKIES1, ref cookies);

                if (cookies == null || cookies.Count < 2)
                {
                    throw new Exception("Session cookies not set");
                }

                _logger.WriteInfoMessage("Authenticate - Authenticating");

                var parameters = string.Format("{0}={1}&{2}={3}", _FIELD_USERNAME, username, _FIELD_PASSWORD, password);
                requester.Post(_URL_LOGIN, parameters, ref cookies);

                if (cookies.Count < 3)
                {
                    throw new Exception("Authentication failed for user " + username);
                }

                return(cookies);
            }
            catch (Exception e)
            {
                _logger.WriteErrorMessage("Authenticate - Error occurred", e);
            }

            return(null);
        }
        public CookieContainer Authenticate(string username, string password)
        {
            try
            {
                var requester = new WebPageRequester(_logger);

                _logger.WriteInfoMessage("Authenticate - Getting session cookies");
                var cookies = new CookieContainer();
                requester.Get(_URL_GETSESSIONCOOKIES1, ref cookies);

                if (cookies == null || cookies.Count < 2)
                    throw new Exception("Session cookies not set"); 
               
                _logger.WriteInfoMessage("Authenticate - Authenticating");

                var parameters = string.Format("{0}={1}&{2}={3}", _FIELD_USERNAME, username, _FIELD_PASSWORD, password);
                requester.Post(_URL_LOGIN, parameters, ref cookies);

                if (cookies.Count < 3)
                    throw new Exception("Authentication failed for user " + username);

                return cookies;
            }
            catch (Exception e)
            {
                _logger.WriteErrorMessage("Authenticate - Error occurred", e);
            }

            return null;
        }