WinForms VS Web
怎么样才能让WinForms程序和Web网站进行Response,Resquest和Cookies通信,就WinForms向网站进行这类操作,不需要调用WebService和Remoting等,就像网站内部通信一样,网站类型不限,可以是Asp.net也可以是JSP或者PHP或者Asp反正什么都行,只要能做到这种通信就可以了,哎。。。啰嗦了。。
------解决方案--------------------using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.IO;
using System.Drawing;
namespace FundindexManager
{
public class HttpAccess
{
#region Construct
public HttpAccess()
{
//
// TODO: Add constructor logic here
//
}
#endregion
#region HttpAccess
#region EncodingName
private string m_encodingName = System.Text.Encoding.Default.BodyName;
public string EncodingName
{
get { return m_encodingName; }
set { m_encodingName = value; }
}
#endregion
#region URL
private string m_URL = " ";
public string URL
{
get { return m_URL; }
set { m_URL = value; }
}
#endregion
#region Post Cookie
private System.Net.CookieCollection m_PostCookie;
public System.Net.CookieCollection PostCookie
{
get { return m_PostCookie; }
set { m_PostCookie = value; }
}
#endregion
#region Get Cookie
private System.Net.CookieCollection m_GetCookie;
public System.Net.CookieCollection GetCookie
{
get { return m_GetCookie; }
set { m_GetCookie = value; }
}
#endregion
#region Post Data
private string m_PostData;
public string PostData
{
get { return m_PostData; }
set { m_PostData = value; }
}
#endregion
#region Request AllowAutoRedirect
private bool m_AllowAutoRedirect = true;
public bool AllowAutoRedirect
{
get { return m_AllowAutoRedirect; }
set { m_AllowAutoRedirect = value; }
}
#endregion
#region Request Method
private string m_RequestMethod = "GET ";
public string RequestMethod
{
get { return m_RequestMethod; }
set { m_RequestMethod = value; }
}
#endregion
#region httpAccess Error
private Exception m_httpAccessError;
public Exception HttpAccessError
{
get { return m_httpAccessError; }
set { m_httpAccessError = value; }
}
#endregion
#region Image
private Image m_WebImage;
public Image WebImage
{
get { return m_WebImage; }
set { m_WebImage = value; }
}
#endregion
#endregion
#region HttpRequestExec
/// <summary>
/// HttpRequestExec
/// </summary>
/// <returns> </returns>
public string HttpRequestExec()
{
HttpWebResponse response = null;
HttpWebRequest request = null;
System.