新手提问: WinForm HttpRequest Session相关的问题
using System;
using System.Net;
using System.Text;
using System.IO;
using System.Threading;
using System.Web;
using System.Text.RegularExpressions;
namespace AutoPM
{
/// <summary>
/// Summary description for PostMessage.
/// </summary>
public class PostMessage
{
private string subject;
private string body;
private string userName;
private string password;
private string loginUrl;
private string semdMessageUrl;
private string cookieHeader;
public PostMessage() : this( " ", " ")
{
//
// TODO:
//
}
public PostMessage(string subject, string body)
{
this.subject = subject;
this.body = body;
}
/// <summary>
/// Message subject
/// </summary>
public string Subject
{
set
{
this.subject = value;
}
}
/// <summary>
/// Message body
/// </summary>
public string Body
{
set
{
this.body = value;
}
}
/// <summary>
/// Login user name
/// </summary>
public string UserName
{
set
{
this.userName = value;
}
}
/// <summary>
/// Login password
/// </summary>
public string Password
{
set
{
this.password = value;
}
}
/// <summary>
/// Login Url address
/// </summary>
public string LoginUrl
{
set
{
this.loginUrl = value;
}
}
/// <summary>
/// Semd private message Url address
/// </summary>
public string SemdMessageUrl
{
set
{
this.semdMessageUrl = value;
}
}
public void SendMessage( int userId )
{
HttpWebResponse response = null;
string result = " ";
try
{
Encoding encoding = System.Text.Encoding.Default;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create( semdMessageUrl );
request.Method = "POST ";
request.Referer = "http://xxxxxxx ";
// Post data
string postData = string.Format( "sTitle={0}&sContent={1} ",
subject,