httpwebrequest post 提交不上去?

来源:百度知道 编辑:UC知道 时间:2024/05/15 11:33:24
源码如下:
try
{
//把sXmlMessage发送到指定的DsmpUrl地址上
string url = @"http://dreamcolor.net/wp-comments-post.php";
string postdata = "author=test&email=test@126.com&url=http://www.test.cn&comment=test11133test&comment_post_ID=429";

Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
byte[] arrB = encode.GetBytes(postdata);
HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(url);
myReq.Method = "POST";
myReq.ContentType = "application/x-www-form-urlencoded";
myReq.ContentLength = arrB.Length;

你用的是什么环境?应该有控件可以用的吧?
比如你使用VS2005,那就可以使用LinkLabel控件,双击,会出现linkLabel1_LinkClicked事件
代码如下:

private void linkLabel1_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
{
try
{
VisitLink();
}
catch (Exception ex )
{
MessageBox.Show("Unable to open link that was clicked.");
}
}

private void VisitLink()
{
// 让linkLabel1的LinkVisited属性为true.
linkLabel1.LinkVisited = true;
//调用Process.Start 方法去打开默认浏览器
//设置一个URL:
System.Diagnostics.Process.Start("http://xiaoqu.koubei.com/community/browse_listing_20.html");
}

c#不是很懂,我这里显示提交成功!
环境:win xp sp3 vs2010

程序有问题!