Add custom header in HttpWebRequest

后端 未结 3 1574
半阙折子戏
半阙折子戏 2020-11-30 02:38

I need to add some custom headers to the HttpWebRequest object. How can I add Custom Header to HttpWebRequest object in Windows Phone 7.

3条回答
  •  醉梦人生
    2020-11-30 03:33

    You use the Headers property with a string index:

    request.Headers["X-My-Custom-Header"] = "the-value";
    

    According to MSDN, this has been available since:

    • Universal Windows Platform 4.5
    • .NET Framework 1.1
    • Portable Class Library
    • Silverlight 2.0
    • Windows Phone Silverlight 7.0
    • Windows Phone 8.1

    https://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.headers(v=vs.110).aspx

提交回复
热议问题