O'Reilly logo

Mastering Internet of Things by Peter Waher

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Returning an XMLresponse

Returning text-based responses is easy. The HttpResponse class derives from TextWriter. There are some things you need to keep in mind, however:

  • Specify the Content Type properly.
  • Don't confuse text encodings. If the text format contains references to the encoding to use, make sure the text encoding matches the Content Type encoding, which will be used for the binary transfer.
  • XML and HTML are examples of text formats normally containing encoding specification as part of the text body.

We begin our response as follows:

private void ReturnMomentaryAsXml(HttpRequest Request, HttpResponse Response) { Response.ContentType = "application/xml"; Response.Write("<?xml version='1.0' encoding='"); Response.Write(Response.Encoding.WebName); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required