March 2018
Beginner to intermediate
410 pages
10h 40m
English
As in the case for the /Momentary resource, we check the Accept header to see how the client wants the response to be represented. If no such header is available, we will assume XML is requested. If an unrecognized content type is requested, we make sure to return a 406 Not Acceptable response before we perform the control action:
if (req.Header.Accept != null) { switch (req.Header.Accept.GetBestContentType("text/xml", "application/xml", "application/json")) { case "text/xml": case "application/xml": await this.SetOutput(OutputValue, req.RemoteEndPoint); this.ReturnMomentaryAsXml(req, resp); break; case "application/json": await this.SetOutput(OutputValue, req.RemoteEndPoint); this.ReturnMomentaryAsJson(req, resp); ...Read now
Unlock full access