Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Capture HTTP request
private string GetRequest()
{
var headers = String.Empty;
StringBuilder sb = new StringBuilder();
sb.AppendLine("URL: " + Context.Request.Url);
sb.AppendLine("IP address:" + Context.Request.UserHostAddress);
sb.AppendLine("HttpMethod " + Request.HttpMethod);
sb.AppendLine("Header:");
foreach (var key in Request.Headers.AllKeys)
sb.AppendLine(key + "=" + Request.Headers[key]);
sb.AppendLine("Body:");
sb.AppendLine(GetDocumentContents(Request));
return sb;
}
private string GetDocumentContents(System.Web.HttpRequest Request)
{
var httpRequestBase = new HttpRequestWrapper(Request);
string documentContents;
using (Stream receiveStream = Request.InputStream)
{
using (StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8))
{
documentContents = readStream.ReadToEnd();
}
}
return documentContents;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.