Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I feel bad for posting this, because the code isnt mine, but i cannot find the original post.</p> <p>This extension method has been extremely useful for me, you simply use it like this: HttpContext.Current.Request.ToRaw();</p> <pre><code>using System.IO; using System.Web; using log4net; namespace System.Web.ExtensionMethods { /// &lt;summary&gt; /// Extension methods for HTTP Request. /// &lt;remarks&gt; /// See the HTTP 1.1 specification http://www.w3.org/Protocols/rfc2616/rfc2616.html /// for details of implementation decisions. /// &lt;/remarks&gt; /// &lt;/summary&gt; public static class HttpRequestExtensions { /// &lt;summary&gt; /// Dump the raw http request to a string. /// &lt;/summary&gt; /// &lt;param name="request"&gt;The &lt;see cref="HttpRequest"/&gt; that should be dumped. &lt;/param&gt; /// &lt;returns&gt;The raw HTTP request.&lt;/returns&gt; public static string ToRaw(this HttpRequest request) { StringWriter writer = new StringWriter(); WriteStartLine(request, writer); WriteHeaders(request, writer); WriteBody(request, writer); return writer.ToString(); } public static string GetBody(this HttpRequest request) { StringWriter writer = new StringWriter(); WriteBody(request, writer); return writer.ToString(); } private static void WriteStartLine(HttpRequest request, StringWriter writer) { const string SPACE = " "; writer.Write(request.HttpMethod); writer.Write(SPACE + request.Url); writer.WriteLine(SPACE + request.ServerVariables["SERVER_PROTOCOL"]); } private static void WriteHeaders(HttpRequest request, StringWriter writer) { foreach (string key in request.Headers.AllKeys) { writer.WriteLine(string.Format("{0}: {1}", key, request.Headers[key])); } writer.WriteLine(); } private static void WriteBody(HttpRequest request, StringWriter writer) { StreamReader reader = new StreamReader(request.InputStream); try { string body = reader.ReadToEnd(); writer.WriteLine(body); } finally { reader.BaseStream.Position = 0; } } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload