使用C#应用程序将对话发送到论坛

问题描述:

我想将对话发送到c#的网站论坛。



我尝试了什么:



I want to send Conversation to a website forums in c#.

What I have tried:

// Create a request and pass the URL to receive the post.
           WebRequest request = WebRequest.Create(uri);
           // We set the Method property of the request to POST.
           request.Method = "POST";
           // We create what is being sent by the POST method and convert it to byte array.
           string postData = "my text message";
           byte[] byteArray = Encoding.UTF8.GetBytes(postData);
           // We set the ContentType of the WebRequest to xml.
           request.ContentType = "text/xml";
           // We set the ContentLength of the WebRequest.
           request.ContentLength = byteArray.Length;
           // We get the request stream.
           Stream dataStream = request.GetRequestStream();
           // write the data to the request stream.
           dataStream.Write(byteArray, 0, byteArray.Length);
           // create the Stream object.
           dataStream.Close();

看看你想要做什么让我觉得你不了解如何构建数据以及页面回发实际上如何运作。如果你这样做,那么问题将会更加不同。



每个网站都不同。此外,似乎有很多其他缺失数据给出消息上下文。最后,基于网络的论坛回发到服务器,通常不是XML格式,而是多部分+ cookie +标题+等...



你用的是像 Fiddler [ ^ ],一个Web调试代理,并在网站上手动完成时查看对话?那次谈话是什么样的?
Looking at what you are trying to do gives me the feeling that you are not understanding how to structure the data and how page post back actually works. If you did, the question would be a lot more different.

Every website is different. Also, there appears to be a lot of "other" missing data to give the message "context". Lastly, web-based forum postbacks, to the server, are usually not in XML but instead are multipart + cookies + headers + etc...

Have you used a tool like Fiddler[^], a Web Debugging Proxy, and peeked at a conversation when done manually on the website? What does that conversation look like?