Ejemplo n.º 1
0
        private bool HandleUnauthenticated()
        {
            var loginClient = new RestTemplate(serviceUrl, cookieContainer);
            var request     = new RestRequest("info", Method.GET);

            request.AddHeader("Accept", "*/*");
            loginClient.Exchange(request);
            return(true);
        }
Ejemplo n.º 2
0
 protected RestService(string serviceUrl, CookieContainer cookieContainer)
 {
     this.serviceUrl      = serviceUrl;
     this.cookieContainer = cookieContainer;
     rest = new RestTemplate(serviceUrl, cookieContainer);
     rest.AddDefaultHeader("X-Requested-With", "XMLHttpRequest");
     rest.AddDefaultHeader("Accept-Language", "zh-CN"); // TODO: i18n
     rest.UnauthenticatedHandler = HandleUnauthenticated;
 }