<p>I have to POST some parameters to a URL outside my network, and the developers on the other side asked me to not use HTTP Parameters: instead I have to post my key-values in <strong>HTTP Headers</strong>.</p>

<p>The fact is that I don't really understand what they mean: I tried to use a ajax-like post, with XmlHttp objects, and also I tried to write in the header with something like</p>

<pre><code>Request.Headers.Add(key,value);
</code></pre>

<p>but I cannot (exception from the framework); I tried the other way around, using the Response object like</p>

<pre><code>Response.AppendHeader("key", "value");
</code></pre>

<p>and then redirect to the page... but this doesn't work, as well.</p>

<p>It's evident, I think, that I'm stuck there, any help?</p>

<hr>

<p><strong>EDIT</strong> I forgot to tell you that my environment is .Net 2.0, c#, on Win server 2003.
The exception I got is</p>

<pre><code>System.PlatformNotSupportedException was unhandled by user code
  Message="Operation is not supported on this platform."
  Source="System.Web"
</code></pre>

<p>This looks like it's caused by my tentative to Request.Add, MS an year ago published some security fixes that don't permit this. </p>

[{'answer_id': 40455, 'author': 'Lasse V. Karlsen', 'author_id': 267, 'author_profile': 'https://Stackoverflow.com/users/267', 'pm_score': 0, 'selected': False, 'text': "<p>You should post more information.</p>\n\n<p>For instance, is this C#? It looks like it, but I might be wrong.</p>\n\n<p>Also, you say you get an exception, what is the exception type and message?</p>\n\n<p>In any case, you can't redirect to a page for POST, you need to submit it from the browser, not from the server redirect, so if you want to automate this, I would guess you would need to generate a html page with a form tag, with some hidden input fields, and then submit it with javascript.</p>\n"}, {'answer_id': 40467, 'author': 'Joel Coehoorn', 'author_id': 3043, 'author_profile': 'https://Stackoverflow.com/users/3043', 'pm_score': 0, 'selected': False, 'text': "<p>I think they mean they don't want you to use URL parameters (GET).  If you use http headers, it's not really querying through POST any more.</p>\n"}, {'answer_id': 40468, 'author': 'Hank Gay', 'author_id': 4203, 'author_profile': 'https://Stackoverflow.com/users/4203', 'pm_score': 0, 'selected': False, 'text': "<p>What language/framework?</p>\n\n<p>Using Python and httplib2, you should be able to do something like:</p>\n\n<pre><code>http = httplib2.Http()\nhttp.request(url, 'POST', headers={'key': 'value'}, body=urllib.urlencode(''))\n</code></pre>\n"}, {'answer_id': 40475, 'author': 'chakrit', 'author_id': 3055, 'author_profile': 'https://Stackoverflow.com/users/3055', 'pm_score': 0, 'selected': False, 'text': "<p>I believe that the Request object would only accept a certain set of predefined headers.</p>\n\n<p>There's an enumeration that lists all the supported HTTP Headers too.</p>\n\n<p>But I can't remember it at the moment... I'll look it up in a sec...</p>\n"}, {'answer_id': 40478, 'author': 'JasonS', 'author_id': 1865, 'author_profile': 'https://Stackoverflow.com/users/1865', 'pm_score': 1, 'selected': False, 'text': '<p>Take a look at HttpWebRequest.  You should be able to construct a request to the URL in question using HttpWebRequest.Method = "POST".</p>\n'}, {'answer_id': 40479, 'author': 'John Rutherford', 'author_id': 3880, 'author_profile': 'https://Stackoverflow.com/users/3880', 'pm_score': 2, 'selected': True, 'text': '<p>Like @lassevk said, a redirect won\'t work.</p>\n\n<p>You should use the WebRequest class to do an HTTP POST from your page or application.  There\'s an example <a href="http://msdn.microsoft.com/en-us/library/debx8sh9.aspx" rel="nofollow noreferrer">here</a>.</p>\n'}, {'answer_id': 40486, 'author': 'Ryan Duffield', 'author_id': 2696, 'author_profile': 'https://Stackoverflow.com/users/2696', 'pm_score': 2, 'selected': False, 'text': '<p>Have you tried the WebClient class?  An example might look like:</p>\n\n<pre><code>        WebClient client = new WebClient();\n        NameValueCollection data = new NameValueCollection();\n        data["var1"] = "var1";\n        client.UploadValues("http://somewhere.com/api", "POST", data);\n</code></pre>\n'}, {'answer_id': 40742, 'author': 'kudlur', 'author_id': 1647, 'author_profile': 'https://Stackoverflow.com/users/1647', 'pm_score': 0, 'selected': False, 'text': '<p>I tested your scenario using 2 sample pages using XmlHttpRequest option.\nCustom headers are available in the aspx page posted to, using XmlHttpRequest.</p>\n\n<p>Create the following 2 pages. Make sure the aspx page is in a solution , so that you can run the in the debugger, set break point and inspect the Request.Header collection.</p>\n\n<p>&lt;html&gt;</p>\n\n<p>&lt;head&gt;</p>\n\n<pre><code>&amp;lt; script language="javascript"&amp;gt;\n\nfunction SendRequest()\n{\n    var r = new XMLHttpRequest();\n    r.open(\'get\', \'http://localhost/TestSite/CheckHeader.aspx\');\n    r.setRequestHeader(\'X-Test\', \'one\');\n    r.setRequestHeader(\'X-Test\', \'two\');\n    r.send(null);\n\n}\n&amp;lt; script / &amp;gt;\n</code></pre>\n\n<p>&lt;/head&gt;\n&lt;body&gt;\n&lt;form&gt;\n&lt;input type="button" value="Click Me" OnClick="SendRequest();" /&gt;\n&lt;/form&gt;\n&lt;/body&gt;\n&lt;/html&gt;</p>\n\n<hr>\n\n<p>CheckHeader.aspx</p>\n\n<p>using System;</p>\n\n<p>using System.Web;</p>\n\n<p>using System.Web.UI;</p>\n\n<p>public partial class CheckHeader : System.Web.UI.Page</p>\n\n<p>{</p>\n\n<pre><code>protected void Page_Load(object sender, EventArgs e)\n{\n    string value = string.Empty;\n    foreach (string key in Request.Headers)\n        value = Request.Headers[key].ToString();\n}\n</code></pre>\n\n<p>}</p>\n\n<p>Man.. This html editor sucks.. or i do not know how to use it...</p>\n'}, {'answer_id': 41831, 'author': 'ila', 'author_id': 1178, 'author_profile': 'https://Stackoverflow.com/users/1178', 'pm_score': 0, 'selected': False, 'text': '<p>The exception I was facing yesterday was caused by my stupid try to write on the headers of the already built page.</p>\n\n<p>When I started creating my Request following one of the mothods indicated here, I could write my headers. </p>\n\n<p>Now I\'m using the WebRequest object, as in the sample indicated by @sectrean, <a href="http://msdn.microsoft.com/en-us/library/debx8sh9.aspx" rel="nofollow noreferrer">here</a>.</p>\n\n<p>Thanks a lot to everybody. StackOverflow rocks :-)</p>\n'}]
['https://Stackoverflow.com/questions/40452', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1178/']