HTTP POST - I'm stuck

I need to send some parameters to a URL outside my network, and the developers on the other hand asked me not to use HTTP parameters: instead, I should publish my key values ​​in HTTP headers .

The thing is, I really don’t understand what they mean: I tried to use an ajax-like record with XmlHttp objects, and also tried to write something like in the header

Request.Headers.Add(key,value);

but I can not (exception from the framework); I tried the opposite using a Response object like

Response.AppendHeader("key", "value");

and then redirect to the page ... but that doesn't work either.

Obviously, I think I'm stuck there, any help?


EDIT I forgot to tell you that my environment is .Net 2.0, C #, on Win server 2003. With the exception I received

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

, Request.Add, MS , .

+5
9

@lassevk, .

WebRequest HTTP POST . .

+1

WebClient? :

        WebClient client = new WebClient();
        NameValueCollection data = new NameValueCollection();
        data["var1"] = "var1";
        client.UploadValues("http://somewhere.com/api", "POST", data);
+3

HttpWebRequest. URL-, HttpWebRequest.Method = "POST".

+1

.

, #? , .

, , , ?

POST, , , , , , html , , javascript.

0

, , , URL (GET). http, POST.

0

/?

Python httplib2, - :

http = httplib2.Http()
http.request(url, 'POST', headers={'key': 'value'}, body=urllib.urlencode(''))
0

, Request .

HTTP-.

... ...

0

, 2 , XmlHttpRequest. aspx, , XmlHttpRequest.

2 . , aspx , , Request.Header.

<HTML>

< >

&lt; script language="javascript"&gt;

function SendRequest()
{
    var r = new XMLHttpRequest();
    r.open('get', 'http://localhost/TestSite/CheckHeader.aspx');
    r.setRequestHeader('X-Test', 'one');
    r.setRequestHeader('X-Test', 'two');
    r.send(null);

}
&lt; script / &gt;

</& GT; & ; > < & GT; < input type="button" value = "Click Me" OnClick = "SendRequest();" / > </ > </ > </HTML>


CheckHeader.aspx

System;

System.Web;

System.Web.UI;

CheckHeader: System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)
{
    string value = string.Empty;
    foreach (string key in Request.Headers)
        value = Request.Headers[key].ToString();
}

}

.. html .. , ...

0

, , .

, mothod, .

WebRequest, , @sectrean, .

. StackOverflow rocks: -)

0

All Articles