0

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?

dmurali
  • 211
  • 1
  • 6
  • 14

1 Answers1

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 our object in this instance.
  • request : Represents our WebRequest
  • Headers : Is the available header content, through our HttpContext.
  • ["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