add header to WebHeaderCollection in POST method windows phone 7

眉间皱痕 提交于 2019-12-25 07:58:20

问题


My server requires us to post a header that include device ID to server, normally we can do some thing like this:

        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(_connectionURL);
        request.ContentType = "application/x-www-form-urlencoded";

        request.Headers.Add    // THIS METHOD DOESN'T EXIST in windows phone 7
        request.Method = "POST";

It has this method, which allows you to set available headers, but the header I want is not included there, how can I add another header to WebHeaderCollection.

request.Headers.AllKeys.SetValue //this function to set the available headers.

回答1:


request.Headers["MyHeaderName"] = "MyHeaderValue";

Some headers are restricted, such as Referrer, and will throw an exception.



来源:https://stackoverflow.com/questions/7116166/add-header-to-webheadercollection-in-post-method-windows-phone-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!