This is the code I'm using, (taken largely from another online source, btw):
string uri = "http://www.blah.com";
// Create my request
HttpWebRequest hwrOrdersIDCallback = (HttpWebRequest)WebRequest.Create(uri);
hwrOrdersIDCallback.KeepAlive = false;
hwrOrdersIDCallback.ProtocolVersion = HttpVersion.Version10;
hwrOrdersIDCallback.Method = "POST";
// Turn the req string into a byte stream
byte[] postBytes = Encoding.ASCII.GetBytes(sbOrderIDsLine.ToString());
// Set content type and stream length
hwrOrdersIDCallback.ContentType = "application/x-www-form-urlencoded";
hwrOrdersIDCallback.ContentLength = postBytes.Length;
Stream requestStream = hwrOrdersIDCallback.GetRequestStream();
// Send the POST
requestStream.Write(postBytes, 0, postBytes.Length);
requestStream.Close();
// Grab the response and display it in a label
HttpWebResponse hwrOrdersIDResponse = (HttpWebResponse)hwrOrdersIDCallback.GetResponse();
label1.Text = (new StreamReader(hwrOrdersIDResponse.GetResponseStream()).ReadToEnd());
I should be getting some specific data back from the server if the POST was completed successfully. I am NOT getting that data and I wanted to know if there was a way to see the information that is getting sent to the server by this POST.
Fiddler2 is a great tool for debugging traffic for ajax/service calls. It monitors traffic, and you can view the details of the calls and see what data is posted and returned.
使用提琴手 。
Create file named <your exe>.config in the application directory and place this inside it:
<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
<system.diagnostics>
<trace autoflush="true" />
<sources>
<source name="System.Net">
<listeners>
<add name="System.Net"/>
</listeners>
</source>
<source name="System.Net.Sockets">
<listeners>
<add name="System.Net"/>
</listeners>
</source>
</sources>
<sharedListeners>
<add name="System.Net"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="System.Net.trace.log"/>
</sharedListeners>
<switches>
<add name="System.Net" value="Verbose" />
<add name="System.Net.Sockets" value="Verbose" />
</switches>
</system.diagnostics>
</configuration>
or use WireShark as others suggested. The trace technique is easier to setup, but harder to read.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.