As I am a C# newbie, it would be really helpful if I could get some support here. I have an Android phone and an application from Android phone should be usable in Windows 8 phone as well. The problem is not with the working of functionalities but the problem is with the transition, it requires just a plugin say a HTTP call with a custom header named Cookie and if I get this, then transition should be quite easier. Can any of you help please?
Asked
Active
Viewed 106 times
1 Answers
1
To reiterate your question, you would like access to the Hypertext Transfer Protocol Header information. Microsoft has really simplified access to such information:
var content = request.Headers["cookie"];
To break it down:
var
: Will dynamically assign the type.content
: Our variable name for ourobject
in this instance.request
: Represents ourWebRequest
Headers
: Is the availableheader
content, through ourHttpContext
.["cookie"]
: Is accessing our header collection, with the name.
You can find more information on headers here and here. I believe the Microsoft Developer Network is currently down for maintenance, so you may have to check in awhile.
A full example would be:
var request = WebRequest.Create("url") as HttpWebRequest;
var response = request.GetWebResponse();
var header = response.Headers["cookie"];
Hopefully this points you in the proper direction.

Greg
- 11,302
- 2
- 48
- 79
-
Thank you Greg! But this is for accessing the headers in the RESPONSE, but now we need to send it in the REQUEST. – dmurali Feb 17 '15 at 15:47
-
@dmurali The example does exactly that at the bottom. – Greg Feb 17 '15 at 15:53