Example #1
1
		/// <summary>
		/// Access specified url.
		/// </summary>
		/// <returns></returns>
		public static TransferResult Transfer(string url, CookieContainer cookieContainer)
		{
			TransferResult rlt = new TransferResult();
			try
			{
				url = ResolveUrl(url);
				HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
				if (cookieContainer != null)
				{
					request.CookieContainer = cookieContainer;
				}
				HttpWebResponse response = (HttpWebResponse)request.GetResponse();
				StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.Default);
				rlt.Result = reader.ReadToEnd();
				rlt.ContentEncoding = reader.CurrentEncoding;
				rlt.ContentType = response.ContentType;
				rlt.Success = true;
			}
			catch (Exception ex)
			{
				Exceptions.LogOnly(ex);
				rlt.Success = false;
			}
			return rlt;
		}
Example #2
0
        /// <summary>
        /// Access specified url.
        /// </summary>
        /// <returns></returns>
        public static TransferResult Transfer(string url, CookieContainer cookieContainer)
        {
            TransferResult rlt = new TransferResult();

            try
            {
                url = ResolveUrl(url);
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                if (cookieContainer != null)
                {
                    request.CookieContainer = cookieContainer;
                }
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                StreamReader    reader   = new StreamReader(response.GetResponseStream(), Encoding.Default);
                rlt.Result          = reader.ReadToEnd();
                rlt.ContentEncoding = reader.CurrentEncoding;
                rlt.ContentType     = response.ContentType;
                rlt.Success         = true;
            }
            catch (Exception ex)
            {
                Exceptions.LogOnly(ex);
                rlt.Success = false;
            }
            return(rlt);
        }