Beispiel #1
0
        public static T PostGetJson <T>(string url, bool haveCookie, Dictionary <string, string> formData = null, Encoding encoding = null)
        {
            CookieContainer container = null;

            if (haveCookie)
            {
                container = new CookieContainer();
                var cookie = System.Web.HttpContext.Current.Request.Cookies.Get("UserInfo");
                if (cookie != null)
                {
                    container.Add(new Cookie {
                        Name = cookie.Name, Domain = ".tsingming.com", Value = cookie.Value, Expires = cookie.Expires
                    });
                }
                //foreach (string key in list.Keys)
                //{
                //    container.Add(new Cookie { Name = key, Domain = System.Configuration.ConfigurationManager.AppSettings.Get("RootDomain"), Value = list[key].Value, Expires = list[key].Expires });
                //}
            }
            string returnText = RequestUtility.HttpPost(url, container, formData, encoding);
            var    result     = GetResult <T>(returnText);

            return(result);
        }
Beispiel #2
0
 public static string GetString(string url, Encoding encoding = null)
 {
     return(RequestUtility.HttpGet(url, encoding));
 }
Beispiel #3
0
        public static T GetJson <T>(string url, Encoding encoding = null)
        {
            string returnText = RequestUtility.HttpGet(url, encoding);

            return(JsonConvert.DeserializeObject <T>(returnText));
        }