在 GetResponse 之前将 HttpWebRequest 视为字符串,而不使用 fiddler
在调用 GetResponse 方法之前如何将 HttpWebRequest 对象视为字符串?我想看到像 fiddler 中这样的请求的原始格式:
Content-Type: multipart/form-data; boundary=---------------------------2600251021003
Content-Length: 338
-----------------------------2600251021003 Content-Disposition: form-data; name="UPLOAD_FILEName"; filename="Searchlight062210 w price.csv" Content-Type: application/vnd.ms-excel
,,,,,
-----------------------------2600251021003
Content-Disposition: form-data; name="submit"
submit
-----------------------------2600251021003--
我尝试了以下代码,但没有成功,因为流不可读。
string GetRequestString(HttpWebRequest req)
{
Stream stream2 = req.GetRequestStream();
StreamReader reader2 = new StreamReader(stream2);
return reader2.ReadToEnd();
}
How can i see HttpWebRequest object as string before calling GetResponse method? I want to see raw format of request something like this as in fiddler:
Content-Type: multipart/form-data; boundary=---------------------------2600251021003
Content-Length: 338
-----------------------------2600251021003 Content-Disposition: form-data; name="UPLOAD_FILEName"; filename="Searchlight062210 w price.csv" Content-Type: application/vnd.ms-excel
,,,,,
-----------------------------2600251021003
Content-Disposition: form-data; name="submit"
submit
-----------------------------2600251021003--
I tried following code, but not worked because stream is not readable.
string GetRequestString(HttpWebRequest req)
{
Stream stream2 = req.GetRequestStream();
StreamReader reader2 = new StreamReader(stream2);
return reader2.ReadToEnd();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果是出于日志记录目的,您可以通过将其放入 app/web.config 来激活跟踪:
运行代码并查看生成的日志文件。
If it is for logging purposes you could activate tracing by putting this in your app/web.config:
Run your code and look at the generated log file.